99/100 on Google Pagespeed Due to Google Analytics

930 views
Skip to first unread message

Jon Farjo

unread,
Jun 1, 2016, 3:40:44 PM6/1/16
to pagespeed-insights-discuss
We have a website builder (blux.com) which we've run through the Google PageSpeed Insights test numerous times. It's a major objective of ours to achieve a perfect ranking. You can see on https://developers.google.com/speed/pagespeed/insights/?url=https%3A%2F%2Fwww.blux.com%2F&tab=mobile that your own Google Analytics script is throwing off an error.

Leverage browser caching
Setting an expiry date or a maximum age in the HTTP headers for static resources instructs the browser to load previously downloaded resources from local disk rather than over the network.
Leverage browser caching for the following cacheable resources:

Anyone know if Google is fixing their own script?

Manuel Becker

unread,
Jun 21, 2016, 4:15:33 AM6/21/16
to pagespeed-insights-discuss

Put the analytics.js on your own server with longer cache times (>7 days). Then (in my case in the js/ folder:

<script>
  (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
  (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
  m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
  })(window,document,'script','js/analytics.js','ga'); /**<= Instead the google URL**/

  ga('create', 'UA-XXXXXXXX-1', 'auto');
  ga('send', 'pageview');

</script>

Have a good one
Reply all
Reply to author
Forward
0 new messages