Skip to content

Instantly share code, notes, and snippets.

@CamdenSegal
Created August 15, 2014 13:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save CamdenSegal/711e18e98d161c40f57d to your computer and use it in GitHub Desktop.
Save CamdenSegal/711e18e98d161c40f57d to your computer and use it in GitHub Desktop.
jQuery selector cache plugin
jQuery.fn.findC = function( selector, reset ) {
var cache = this.data('jcache') || {};
if ( reset || undefined === cache[ selector ] ) {
cache[ selector ] = this.find( selector );
}
this.data( 'jcache', cache );
return cache[ selector ];
};
$jqueryObject.findC( '.new-selector' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment