This pull request proposes to create the Google Tag Manager script using the async attribute on the script element` (see MDN reference).
The DAP script appends a Google Tag Manager script to the page, but it does so without marking the script as asynchronous. This causes the script to block the main thread, impacting user-facing performance.
This reflects in performance audits of our site, which flag Google Tag Manager as blocking main thread for upward of 300ms.
This pull request proposes to create the Google Tag Manager script using the
async
attribute on thescript
element` (see MDN reference).The DAP script appends a Google Tag Manager script to the page, but it does so without marking the script as asynchronous. This causes the script to block the main thread, impacting user-facing performance.
This reflects in performance audits of our site, which flag Google Tag Manager as blocking main thread for upward of 300ms.
Related resource: https://web.dev/articles/optimizing-content-efficiency-loading-third-party-javascript#async-defer
Google's documentation for Google Tag Manager also uses
async
in its own default script snippet examples: