Last active
June 10, 2020 17:01
-
-
Save nathansmith/942745 to your computer and use it in GitHub Desktop.
Force yourself to learn JavaScript.
This file contains 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
// 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); |
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.
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. :)
Nice. I can imagine this as Chromium or Firefox plugin (or bookmarklet at least) :-D
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
Evil indeed! :) You could rewrite this as
$ = $$ = dojo = Ext = jQuery = SC = YAHOO = YUI = Zepto = null;
if you wanted to.