Skip to content

24 ways to impress your friends

Vote down?

Andy Davies

Layering into separate files might be good from a code organisation point of view but increases the number of requests the browser has to make and so can have an adverse affect on performance.

From the perfomance angle we encourage people to merge files together (especially small ones) to reduce the number of requests but finding the sweet spot between reducing requests and making most effective use of parallel downloads often requires some experimentation.

One thing we would encourage people to avoid is document.write for inserting scripts.

Steve Souders explains it well here: but basically using document.write to insert a script prevents the browser from rendering all DOM elements below it until the script has downloaded.

Much better to use the async loading pattern that Steve mentions.