Created
June 19, 2019 15:45
-
-
Save Kcko/ac714f2bab7cb161a34f36b82346d0b9 to your computer and use it in GitHub Desktop.
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
function Selector_Cache() { | |
var collection = {}; | |
function get_from_cache( selector ) { | |
if ( undefined === collection[ selector ] ) { | |
collection[ selector ] = $( selector ); | |
} | |
return collection[ selector ]; | |
} | |
return { get: get_from_cache }; | |
} | |
var selectors = new Selector_Cache(); | |
// Usage $( '#element' ) becomes | |
selectors.get( '#element' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment