How To Load gtag.js Or JavaScript Tags Faster For Core Vitals (Not Locally)

Before you delay javascript, you should know that you could be destroying your website. Not to mention, any plugin that uses javascript (all most all of them) can severely slow down your website, causing loss of conversions and sales. Most importantly, a website that optimizes javascript loading may hinder tracking and data collection.

  • But google wants us to optimize for speed?
  • And, they want us to ask for consent?
  • Oh, and shouldn’t your website be accessible too?

It’s a little contradictory – when google is asking us to optimize website speed, user accessibility, and data tracking. Combined with the other website features and functions, it’s increasingly harder to boost performance and drive ROI.

Google recommends using Javascript very carefully – putting users first, not search engines. Your content should follow the best practices and avoid lazy-loading content.

I don’t recommend you do this. Always have a back up. But, in my case, to be sure for this client, I’m removing:

  • Accessibility plugins
  • Compliance plugins
  • Local Tracking plugins

Which JavaScript To Prioritize? What’s Most Important?

Since many website use plugins for tracking, consent, and accessibility. It might be a good starting point to disable these options. First priority is data tracking, conversions and performance.

Also take an inventory of JavaScript Errors that could harm your SEO. Use the chrome or firefox console to identify errors such as:

  • WordPress Gravatar Scripts Misfiring
  • Plugin Recognition Not Supported
  • Overwritten Value Of Attributes (duplicated cookies)
  • Partitioned Cookies or Storage Access
  • Blocked Requests For Cookies
  • Google Tag Manager Errors
  • gtag.js script errors
  • Google Ads script errors
  • Meta or Facebook script loading
  • 3rd Party Tracking Script speed
  • Plugin Conflicts and Errors

To optimize WordPress speed and tracking data, we are forced to pass certain JavaScript threads directly through, adding exceptions for the JavaScript delay.

Before proceeding, here’s a brief understanding of deferring JavaScript vs delaying JavaScript.

Delay vs Defer Javascript

When you delay JavaScript, you are telling the browser not to load the script until AFTER THE USER TAKES AN ACTION. That means, if the user does not take any action, your scripts may not ever load. This is an important distinction. If you choose to delay all JavaScript on a website, then your tracking scripts may never trigger – leading to lost data and potential revenues.

When you defer JavaScript, the scripts are loaded after the page is rendered. This ensures the loading of specific scripts. However, it will have less impact on your Core Vital scores – increasing the overall execution, size, and page load.

Page speed optimization plugins often offer a combination of JavaScript delay or defer options. In fact, you can use them in combination. Before configuring your website, work with a provider who understands the nuances of your theme, plugins and caching.

These are not changes anyone should make lightly.

In conclusion, we were able to streamline the JavaScript code by reordering the scripts carefully, using deferred scripts, and removing necessary load.

Get A Free SEO Audit Report

More Posts

Share:

Get A Free SEO Audit Report