I'm trying to optimize a web site to score above 90 on google page insights both on mobile and desktop. Now my desktop score is fine but on mobile I get around 80 and the main reason for that according to google test is Reduce the impact of third-party code Third-party code blocked the main thread for which is jquery CDN load time. It is loaded through google CDN and I've been trying for 3 days now to find a solution online but no luck. I cannot defer
or async
it as it breaks my site. Can anyone shed some light on how to achieve this? Thanks
CodePudding user response:
Okay so I've came to a solution and decided to post it here, maybe someone finds it helpful in the future.
So adding defer
to the script did help but one out of three page speed insight checks would still come over 500ms for total blocking time. So what I did was copy the jquery code and added it directly to <script></script>
tags in the header of the file. Every check from then on was 0-40ms on mobile 0-20ms for desktop.