Skip to content

Instantly share code, notes, and snippets.

@nathansmith
Last active June 10, 2020 17:01
Show Gist options
  • Save nathansmith/942745 to your computer and use it in GitHub Desktop.
Save nathansmith/942745 to your computer and use it in GitHub Desktop.
Force yourself to learn JavaScript.
// If you're a glutton for punishment, and/or claim
// that JavaScript libraries have too much "bloat",
// use this to force yourself to write JS longhand.
(function(window) {
function screwed() {
window._ = null;
window.$ = null;
window.$A = null;
window.$F = null;
window.$H = null;
window.$R = null;
window.$w = null;
window.$defined = null;
window.$type = null;
window.$merge = null;
window.$extend = null;
window.$native = null;
window.$chk = null;
window.$pick = null;
window.$random = null;
window.$time = null;
window.$clear = null;
window.$$ = null;
window.dojo = null;
window.Ext = null;
window.jQuery = null;
window.SC = null;
window.YAHOO = null;
window.YUI = null;
window.Zepto = null;
window.setTimeout(screwed, 100);
}
screwed();
})(this);
@mathiasbynens
Copy link

Evil indeed! :) You could rewrite this as $ = $$ = dojo = Ext = jQuery = SC = YAHOO = YUI = Zepto = null; if you wanted to.

@padolsey
Copy link

The worst offenders won't be affected by this though :( ... I'm talking of those who dare to encroach upon the sanctity of unaltered DOM/BOM prototypes. MOOTOOLS... PROTOTYPE... Those bastards.

@nathansmith
Copy link
Author

True. I mean, the DOM remains extended/polluted, but good luck trying to use the "getters" of $ or $$.

Which reminds me, added: $A, $F, $R, $w too. :)

@Harvie
Copy link

Harvie commented May 31, 2011

Nice. I can imagine this as Chromium or Firefox plugin (or bookmarklet at least) :-D

@KTibow
Copy link

KTibow commented Jun 10, 2020

Short-hand one-time alternative:

window._ = window.$ = window.$A = window.$F = window.$H = window.$R = window.$w = window.$defined = window.$type = window.$merge = window.$extend = window.$native = window.$chk = window.$pick = window.$random = window.$time = window.$clear = window.$$ = window.dojo = window.Ext = window.jQuery = window.SC = window.YAHOO = window.YUI = window.Zepto = null;

Or even shorter:

_=$=$A=$F=$H=$R=$w=$defined=$type=$merge=$extend=$native=$chk=$pick=$random=$time=$clear=$$=dojo=Ext=jQuery=SC=YAHOO=YUI=Zepto=null;

For self-calling:

function z7(){_=$=$A=$F=$H=$R=$w=$defined=$type=$merge=$extend=$native=$chk=$pick=$random=$time=$clear=$$=dojo=Ext=jQuery=SC=YAHOO=YUI=Zepto=null;setTimeout(z7,9);}z7();

And pretty much ruin most scripts:

function z7(){_=$=$A=$F=$H=$R=$w=$defined=$type=$merge=$extend=$native=$chk=$pick=$random=$time=$clear=$$=dojo=Ext=jQuery=SC=YAHOO=YUI=Zepto=document.getElementById=document.getElementByClassName=document.getElementByName=document.getElementByTagName=document.getElementByTagNameNS=null;setTimeout(z7,9);}z7();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment