Avoid Document.Write to Fetch External Resources


For viewing all tips see here


Applicable To
All modern browsers

How Improves Page Load Time
o        By optimizing parallelization of external resource downloads
o        By optimizing browser rendering


Prologue
Modern browsers use speculative parsers to efficiently discover external resources referenced in HTML document, which reduces significantly the page load time.  Speculative parsers are light and fast and don’t execute Java Script


Why
o        Avoiding it helps speculative parsers to take intelligent decisions on external resources downloading and consequently progressive rendering
o        It avoids serialization of downloads of external resources and hence significantly reduce the page load time.


How
o        Declare external resources directly in HTML markup as it might allow speculative parsers to locate these resources without parsing the JavaScript code.


Exceptions
None


Recommendations
In case document.write cannot be avoided then use asynchronous techniques to defer loading the resources.  The other alternative could be to use “iFrames” instead but it is not preferable.

Comments

Popular posts from this blog

Performance Test Run Report Template

Bugs Management in Agile Project

Understanding Blockchain