1// Create our stylesheet
2var style = document.createElement('style');
3style.innerHTML =
4 '.some-element {' +
5 'color: purple;' +
6 'background-color: #e5e5e5;' +
7 'height: 150px;' +
8 '}';
9
10// Get the first script tag
11var ref = document.querySelector('script');
12
13// Insert our new styles before the first script tag
14ref.parentNode.insertBefore(style, ref);
15