Edit in JSFiddle

var sheet = (function() {
	// Create the <style> tag
	var style = document.createElement('style');

	// Add a media (and/or media query) here if you'd like!
	// style.setAttribute('media', 'screen')
	// style.setAttribute('media', 'only screen and (max-width : 1024px)')

	// WebKit hack :(
	style.appendChild(document.createTextNode(''));

	// Add the <style> element to the page
	document.head.appendChild(style);

	return style.sheet;
})();



// Test
sheet.insertRule("body { background: blue; }", 0);



<html>
<body>
The sheet.insertRule() function should have changed the background colour to blue...
</body>
</html>
body {
  font-family: arial;
}