Skip to content

Performance: Defer GTM script

Administrator requested to merge tr/gtm-defer into main

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

Merge request reports

Loading