Skip to content

Commit 0949b19

Browse files
committed
append script after event listeners are added for IE
1 parent 709c2ba commit 0949b19

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

index.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,16 +29,17 @@ module.exports = function loadScript (options, callback) {
2929
script.async = true;
3030
script.src = options.src;
3131

32-
var firstScript = document.getElementsByTagName('script')[0];
33-
firstScript.parentNode.insertBefore(script, firstScript);
34-
3532
// If we have a callback, attach event handlers, even in IE. Based off of
3633
// the Third-Party Javascript script loading example:
3734
// https://github.com/thirdpartyjs/thirdpartyjs-code/blob/master/examples/templates/02/loading-files/index.html
3835
if (callback && type(callback) === 'function') {
3936
onload(script, callback);
4037
}
4138

39+
// Append after event listeners are attached for IE.
40+
var firstScript = document.getElementsByTagName('script')[0];
41+
firstScript.parentNode.insertBefore(script, firstScript);
42+
4243
// Return the script element in case they want to do anything special, like
4344
// give it an ID or attributes.
4445
return script;

0 commit comments

Comments
 (0)