1

We are using Google Analytics on our website. The last two resources loaded are from googletagmanager.com and google-analytics.com. The download time for these two resources is a total of 370ms for users distant from our web server (San Jose, CA to Sydney, Australia). This is a great deal of time compared to our On Load time of 1.1 seconds.

Our first attempt to increase the performance of this website was to add the following code:

<link rel="preconnect" href="https://www.googletagmanager.com/" crossorigin="anonymous" />
<link rel="dns-prefetch" href="https://www.googletagmanager.com/" />
<link rel="preconnect" href="https://www.google-analytics.com/" crossorigin="anonymous" />
<link rel="dns-prefetch" href="https://www.google-analytics.com/" />

This eliminated the dns query times. This change is included in the performance timings stated above.

We are trying to:

<link rel="preload" as="script" href="https://www.google-analytics.com/analytics.js" type="script" crossorigin="anonymous" />

This is causing a CORS error, "Ensure CORS response header values are valid". How should I correct this error? Is it a good idea to prefect this script?

2
  • Google analytics should be loading asynchronously and it doesn't need to load before your site starts functioning. Is there a reason that you need to improve its load time? Users shouldn't notice the delay. Dec 19 '21 at 23:13
  • We have "<script async src="/sites/default/files/google_analytics/gtag.js?r4dzme"></script>" at the very top of <head> -- thus async is in place. As I mentioned above, about 1/3 of our webpage OnLoad time is google analytics. Should I not be concerned about this?
    – Greg Sims
    Dec 20 '21 at 1:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.