Combine External JS / CSS Files into Few Files


For viewing all tips see here


Applicable To
All Browsers


How Improves Page Load Time
By optimizing number of network round trips


Prologue
It is very common in development to build application with modular, reusable components but that might leads to multiple JS / CSS Files, which need to be downloaded separately.  It introduces delays and increases the page load time.  Combining external JS / CSS into few files cut down extra roundtrips and hence improves the page load time.


Why
o        To minimize the number of roundtrips
o        To avoid blocking of further download of other resources due to JS / CSS processing


How
o        Use different JS / CSS files during the development cycle and then merge during the deployment process.


Exceptions
o        There are some cases where JS / CSS code need different versioning and combining those files with other can’t be a possibility
o        JS files are being served from external third party domains


Recommendations
o        It is recommended to have 2-3 external JS / CSS files
o        Partition the JS / CSS into two files, one minimal JS / CSS file that is needed to render the page at startup and other that might be required after page load.
o        Have java script / CSS of rarely used components in its own file and serve it only when the component is requested by user
o        For small code of java scripts / CSS, which shouldn’t be cached, it can be in lined 

Comments

Popular posts from this blog

Performance Test Run Report Template

Understanding Blockchain

Bugs Management in Agile Project