Use $.data Instead of $.fn.data
Prev Chapter 9. Performance Best Practices Next

Use $.data Instead of $.fn.data

Using $.data on a DOM element instead of calling $.fn.data on a jQuery selection can be up to 10 times faster. Be sure you understand the difference between a DOM element and a jQuery selection before doing this, though.

// regular 
$(elem).data(key,value);



// 10x faster

$.data(elem,key,value);

Copyright Rebecca Murphey, released under the Creative Commons Attribution-Share Alike 3.0 United States license.


Prev Up Next
Use Stylesheets for Changing CSS on Many Elements Home Don't Act on Absent Elements