Closed
Description
Originally reported by pferreir at: http://bugs.jquery.com/ticket/10495
While trying to inject the Facebook "like button" JS in a page in execution time, I got some funny behavior:
var fjs = $('script:first'); $('<script/>').attr({'async': true, 'src': '//connect.facebook.net/en_US/all.js#xfbml=1&appId=xxx'}).insertBefore(fjs)
fails (same with the equivalent before() call).
While
var fjs = $('script:first').get(0); var e = $('<script/>').attr({'async': true, 'src': '//connect.facebook.net/en_US/all.js#xfbml=1&appId=xxx'}).get(0); fjs.parentNode.insertBefore(e, fjs)
works just ok.
I tried different combinations of native/jQuery elements and they all fail. This happens at least since 1.6.1.
Issue reported for jQuery git