We often get the question "my web developer says the ActiveDEMAND tracking script is making my page slow to load, does your script slow down my site?". Often web developers will reference a waterfall diagram which will show that the ActiveDEMAND tracking script takes time to load, thus the inference is that the page is being blocked by the tracking script. In reality, the tracking script does not impact page load speed. The tracking script is a tiny file that is loaded asynchronously. The default deployment of the tracking script is async, defer. You can read about this here
https://javascript.info/script-async-defer
From the above page
"
defer
- Scripts with
defer
never block the page. - Scripts with
defer
always execute when the DOM is ready (but beforeDOMContentLoaded
event).
async
The async
attribute means that a script is completely independent:
- The browser doesn’t block on
async
scripts (likedefer
). - Other scripts don’t wait for
async
scripts, andasync
scripts don’t wait for them. DOMContentLoaded
and async scripts don’t wait for each other:DOMContentLoaded
may happen both before an async script (if an async script finishes loading after the page is complete)- …or after an async script (if an async script is short or was in HTTP-cache)
Order | DOMContentLoaded |
|
---|---|---|
async |
Load-first order. Their document order doesn’t matter – which loads first runs first | Irrelevant. May load and execute while the document has not yet been fully downloaded. That happens if scripts are small or cached, and the document is long enough. |
defer |
Document order (as they go in the document). | Execute after the document is loaded and parsed (they wait if needed), right before DOMContentLoaded . |
"
This implies that the page load happens regardless of whether the tracking script is fully loaded on the page.
Comments
Please sign in to leave a comment.