why insertBefore not appendChild?
/** * Evalulates a script in a global context. */ globalEval: function(data) { if (data && REG_NOT_WHITE.test(data)) { // Inspired by code by Andrea Giammarchi // http://webreflection.blogspot.com/2007/08/global-scope-evaluation-and-dom.html var head = doc.getElementsByTagName('head')[0] || doc.documentElement, script = doc.createElement('script'); // It works! All browsers support! script.text = data; // Use insertBefore instead of appendChild to circumvent an IE6 bug. // This arises when a base node is used. head.insertBefore(script, head.firstChild); head.removeChild(script); } } });