Skip to content

Instantly share code, notes, and snippets.

@fdaciuk
Last active December 26, 2015 02:18
Show Gist options
  • Save fdaciuk/7076966 to your computer and use it in GitHub Desktop.
Save fdaciuk/7076966 to your computer and use it in GitHub Desktop.
Cache para objetos jQuery Referência: https://coderwall.com/p/q19via JSPerf: http://jsperf.com/jquery-cached-domcache
$c = (function( $ ) {
var DOMCACHESTORE = {};
return function( selector, force ) {
if ( force || undefined === DOMCACHESTORE[selector] ) {
DOMCACHESTORE[selector] = $(selector);
}
return DOMCACHESTORE[selector];
};
})( jQuery );
$c( 'h2' ).addClass( 'secondary-title' ).text( 'Title' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment