Jump to content

External javascript include and concatinate


soduno

Recommended Posts

We currently have a bunch of external javascript files included at our shop.

Trustpilot, Hotjar etc...

 

Only problem is that Google pagespeed is freakin' out because of too many requests.

What is the standard procedure in Prestashop to include JS? Right now we a simply including them

manually in the theme's footer file, but there must be another way to do that, and also a way in Prestashop

to concatenate the external scripts?

 

 

Best, Simon :)

Edited by soduno (see edit history)
Link to comment
Share on other sites

You can't concatenate external scripts... the main issue here is, well... they are external! 

 

And adding them in the footer file is just right, unless someone creates a module to handle the added code better, but the result is the same. A module of course has the possibility to include the external javascript only on specific pages (as example the confirmation page), if it's relevant. But otherwise, there's essentially no difference.

 

You might want to remove some external services, if you have way too many. Or you might want to try something like the Google Tag Manager, this might improve your shop's speed. 

Edited by innovacy (see edit history)
Link to comment
Share on other sites

Thank you very much for your advice. It helped a lot. I realize that the problem was (as you wrote) external scripts.

Right now I have added them to load locally instead and as I can see, the performance has gained aprox 50%.

 

According to scripts. Is there a way to concatenate locally loaded scripts in Prestashop?
I could use gulp, however I am not sure if it would crack the modules. 

I will definitely check Google Tag Manager out :)

 

You can't concatenate external scripts... the main issue here is, well... they are external! 

 

And adding them in the footer file is just right, unless someone creates a module to handle the added code better, but the result is the same. A module of course has the possibility to include the external javascript only on specific pages (as example the confirmation page), if it's relevant. But otherwise, there's essentially no difference.

 

You might want to remove some external services, if you have way too many. Or you might want to try something like the Google Tag Manager, this might improve your shop's speed. 

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...