- TLC Home Home
- Discussions Discussions
- Documentation Documentation
- Knowledge Base Knowledge Base
- Education Education
- Blog Blog
- Support Desk Support Desk
02-20-2023 09:44 PM
04-14-2023 03:19 AM
Loading the utag.js script using the defer attribute can have some pros and cons. Let's discuss the possible cons of using defer:
Delayed tag firing: The defer attribute ensures that the utag.js script is executed only after the HTML document has been fully parsed. This can cause tags to fire later than they would without the defer attribute, potentially leading to missed or delayed data collection for events or user interactions that occur early in the page load.
Dependencies on utag.js: If you have other scripts on your page that rely on Tealium functions or variables, loading utag.js with defer may cause issues if these dependent scripts execute before utag.js is loaded. This can lead to errors or incorrect data being sent to your tags.
Tag prioritization: When using the defer attribute, it may become more difficult to manage tag prioritization, as all deferred scripts will execute in the order they appear in the HTML. This can lead to issues if certain tags need to fire before others, or if there are dependencies between tags.
Potential loss of data: Depending on the implementation, loading utag.js with defer could potentially cause a loss of data for certain tags if the user leaves the page or interacts with elements before the script has loaded and executed.
While using the defer attribute can have some drawbacks, it can also help improve page load performance by allowing the browser to continue parsing and rendering the rest of the page without waiting for the utag.js script to load and execute. To decide whether to use defer, you'll need to carefully consider the potential impact on data collection and the dependencies between scripts on your site.
If you decide to use the defer attribute, it's crucial to thoroughly test your implementation to ensure that data collection is accurate and that all dependencies are correctly managed.
Copyright All Rights Reserved © 2008-2023