Adding scripts - product page vs theme.liquid for speed

Adding scripts - product page vs theme.liquid for speed

George_Greenhil
Trailblazer
175 0 59

Hey guys,

 

I'm looking to improve my site speed, we've just moved to an OS2.0 theme so now can add custom liquid to product pages with sections intheme customiser.

 

For most app scripts you're told to add code the scripts to theme.liquid but if its something for the product page, does adding it in custom sections almost add a conditional load meaning other pages don't have to load the files like it would if you added it to theme.liquid which should then improve load on other pages?

 

 

For example, the Klaviyo back in stock code attached below - is this able to be transferred just on the product page instead of being in theme.liquid for speed improvements as shown below? Or will it not make any difference to speed?

 

Screenshot 2022-10-03 at 13.01.29.pngScreenshot 2022-10-03 at 22.39.04.png

Replies 2 (2)
George_Greenhil
Trailblazer
175 0 59

Hey @Ecom_Swift 

 

Thanks for getting back to me but I was looking to find out if scripts added on product page custom liquid blocks will help with speed or if its better to add scripts directly to theme.liquid.

 

Thanks,

George

flareAI
Shopify Partner
2405 224 549

Hello @George_Greenhil,


I'm Gina - Product Manager at flareAI. flareAI has helped Shopify stores generate $5+ million in sales from Google Search, on autopilot.


If it's helpful to you, please let me know by giving it a like or marking it as a solution.


It really depends upon the Shopify app. Some apps will check the app snippet in theme.liquid and some apps in other related snippets like the product. It's better to include the app snippet in whatever file the app is advising to include, to avoid any glitches.


I hope that this helps


Gina
flareAI

flareAI : Get Sales from Google Search, on Autopilot
$10+ billion in eCommerce on Google Search, every day. Find out how much you are missing