h5bp/html5please-api — Issue #52: On setting src on a script element
Author: zcorpan
Created: 2012-02-28 07:45:12+00:00
State: open

The "Here is your widget" boilerplate that uses Modernizr has this:

var ref = document.getElementsByTagName('script')[0]; var url = 'http://api.html5please.com/' + features.join('+') + '.json?callback=Modernizr.html5please.cb' + opts.options ? ('&' + opts.options) : ''; script.src = url; ref.parentNode.insertBefore(script, ref); return false; };

Does this even work? Scripts are generally marked as "already executed" and then don't want to execute again. Or what if the first script element is a data block (i.e. has a type="" attribute that causes the script to not be executed)? Also, "what if two scripts did this?" (http://blogs.msdn.com/b/oldnewthing/archive/2005/06/07/426294.aspx ).

Why not just create a new script element?