Skip to content

Instantly share code, notes, and snippets.

@blois
blois / gist:8926615
Created February 10, 2014 23:49
Document.currentScript workaround
function getCurrentScript(callback) {
if (document.currentScript) {
callback(document.currentScript);
return;
}
var scripts = document.scripts;
function onLoad() {
for (var i = 0; i < scripts.length; ++i) {
scripts[i].removeEventListener('load', onLoad, false);
}