Created
November 5, 2011 18:56
-
-
Save 3rd-Eden/1341882 to your computer and use it in GitHub Desktop.
custom script loader
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function (global) { | |
var _namespace = global.namespace | |
, namespace = {}; | |
namespace.push = function push (fn) { | |
return fn && typeof fn === 'function' && fn(namespace); | |
}; | |
if (_namespace && _namespace.length) { | |
var i = _namespace.length; | |
while (i--) namespace.push(_namespace[i]); | |
} | |
}(this)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function (a, b, c, d, e, f){ | |
for (d = c.length, f = a.getElementsByTagName(b)[0]; d--;) { | |
e = a.createElement(b); | |
e.src = c[d]; | |
f.parentNode.insertBefore(e, f); | |
} | |
})( | |
document | |
, 'script' | |
, [ | |
'http://cdn.example.com/core.js' | |
, 'http://cdn2.example.org/page.js' | |
] | |
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
('namespace' in this ? namespace : (namespace = [])).push(function push (namespace) { | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
nice