Skip to content

Instantly share code, notes, and snippets.

@ElliotChong
Last active August 29, 2015 14:14
Show Gist options
  • Save ElliotChong/eb6003acde2ceb11f786 to your computer and use it in GitHub Desktop.
Save ElliotChong/eb6003acde2ceb11f786 to your computer and use it in GitHub Desktop.
When you're the only script that should work on a page.
var HighlanderJS = (function (immortals) {
var highlander = {};
for (var immortal in immortals) {
highlander[immortal] = immortals[immortal];
delete immortals[immortal];
}
immortals.HighlanderJS = function (onlyOne) {
onlyOne.apply(highlander);
};
return immortals.HighlanderJS;
})(window);
HighlanderJS(function () { alert("lolz"); });
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment