Skip to content

24 ways to impress your friends

Vote down?


Using document.write like you did is bad because fetching resources asynchronously prevents those resources from blocking the page load.

Using a script DOM element maximizes asynchronous loading across current browsers:

var node = document.createElement(‘link’);
node.type = ‘text/css’;
node.async = true;
node.src = ‘example.css’;
// Now insert the node into the DOM, perhaps using insertBefore()