Last active
August 29, 2015 14:15
-
-
Save bmcalister/d88401c1a25279c9e610 to your computer and use it in GitHub Desktop.
jQuery selector cache
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
window._$ = (function($, undefined){ | |
var cache = []; | |
return function(selector, update) { | |
if( cache[ selector ] === undefined || update === true ) { | |
cache[ selector ] = $(selector); | |
} | |
return cache[ selector ]; | |
} | |
})(jQuery); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment