Jump to content

Moving all Scripts from the header to the footer


Air Chaser

Recommended Posts

Hi,

 

So, I have been working on revamping a website and I have to move all the inline and header JavaScript and to the footer of the site. In other platforms it has been a pretty straight forward process, I hope Prestashop is no different. 

For What I understand so far of the platform I have 3 options how to go about it.

  1.  Create a custom hook on the footer of the site, create a custom module and hook all my scripts using the module and if statements. This sounds like a hack though.
  2. Create a custom hook and somehow attached the scripts from individual controllers. This would best case scenario but I can't figure out how to connect ProductControllerCore.php for example to a custom hook to accomplished this.
  3. The most viable option I can think of right now, is to place all the scripts directly onto the footer.tpl and using individual controllers set smarty variables to let scripts display or hide scripts depending on the controllers needs. This one feels like a hack as well but I cant really think of any other way.

 

Any help or insight into this issue would very much appreciated.

Link to comment
Share on other sites

hello

prestashop has option to move scripts by default, its available from preferences > performance section.

You dont have to create new hooks, modify modules to support these new positions.

just one simple switch on preferences > performance page.

  • Like 2
Link to comment
Share on other sites

  • 11 months later...

hello

prestashop has option to move scripts by default, its available from preferences > performance section.

You dont have to create new hooks, modify modules to support these new positions.

just one simple switch on preferences > performance page.

 

Which is the option in Prestashop 1.7 to move all the scripts? 

  • Like 1
Link to comment
Share on other sites

  • 9 months later...
  • 2 years later...
On 5/3/2016 at 2:20 PM, vekia said:

hello

prestashop has option to move scripts by default, its available from preferences > performance section.

You dont have to create new hooks, modify modules to support these new positions.

just one simple switch on preferences > performance page.

Thankyou so much vekia you saved my time

Link to comment
Share on other sites

  • 1 year later...

But in that way I have to move manually all the modules hook, and I'm not sure if this doesn't cause any problems to them.

I was wondering if there's an option to tell prestashop to load everything on top or bottom, because I saw that prestashop demo website load all js files into the footer, while on my website they're all loaded into the header.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...