Performance: Defer GTM script
Created by: umpox
One liner to get some minor performance gains.
Previously the GTM script uses async
, so the script will be downloaded as the HTML is parsed, but will block parsing when the script is ready so it can be executed. This has the potential to slightly reduce performance, especially when the GTM script is cached so will be considered "downloaded" immediately.
Now the GTM script will use defer
, so will never block HTML parsing, and ensure that it is de-prioritised over essential assets such as CSS styles.
Closes https://github.com/sourcegraph/sourcegraph/issues/24880