I am trying to improve my page load speed but I need to run a few scripts, is it better to use Google tag manager, code injection or add the scripts to the theme file directly
- Cookie banner
- Google Adsense
- Meta pixel
- TOC
I am trying to improve my page load speed but I need to run a few scripts, is it better to use Google tag manager, code injection or add the scripts to the theme file directly
I don’t think there’d be a significant performance difference with these options. Here, I’d opt for whichever method is easiest to use and maintain.
Thanks for the feedback Ryan.
Is there a way to delay scripts like you can in GTM but in code injection or theme files?
Do you know how to address ‘reduce unused JavaScript’ on PageSpeed tests? It shows stripe and search and affecting my scores
You can conditionally load and run scripts using the usual tools at your disposal (like async
and defer
) as well as with Ghost-specific helpers (e.g., only loading certain scripts depending on the context with the is
helper).
These scripts are necessary for membership and search. They’re also already optimized. If your site doesn’t feel slow or sluggish, then you’re good. Also, as Google notes, those numbers don’t affect your score directly and only tell some of the story.
For example, here’s the pagespeed for the NY Times: