Skip to content

Instantly share code, notes, and snippets.

@riverspirit
Created June 13, 2014 06:00
Show Gist options
  • Save riverspirit/fd0efae9ac732f8ddd1a to your computer and use it in GitHub Desktop.
Save riverspirit/fd0efae9ac732f8ddd1a to your computer and use it in GitHub Desktop.
Load javascript file dynamically and call a function from it
(function (d, f, a) {
// Your settings here
var o = {
maxLinks: 4,
searchElements: ['div', 'h'],
linkClass: 'link-to-mdn',
extraLinks: {
'keywordx': 'http://example.com'
}
};
var s = d.createElement("script");
s.type = "text/javascript";
if (s.f) {
s.a = function () {
if (s.f == "loaded" || s.f == "complete") {
s.a = null;
PromoteMDN(o)
}
}
} else {
s.onload = function () {
PromoteMDN(o)
}
}
s.src = "promote-mdn.js";
d.getElementsByTagName("head")[0].appendChild(s)
})(document, 'readyState', 'onreadystatechange');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment