3 ms·
A couple of notes: if you care about performance, use $.data(), i.e. instead of $('body').data(key, value) use $.data(document.body, key, value). Also .data()
by rimantas 15y ago
A couple of notes: if you care about performance, use $.data(), i.e. instead of $('body').data(key, value) use
$.data(document.body, key, value).
Also .data() lets you access HTML5 data-* attributes. Note, that doing so values are converted to proper objects if possible. See http://jsfiddle.net/wLfJV/1/ http://jsfiddle.net/wLfJV/1/
Unrelated, but worth reminding: don't use $(this).attr('id')— this.id is simpler and much much faster: http://jsperf.com/el-attr-id-vs-el-id/2 http://jsperf.com/el-attr-id-vs-el-id/2
- filipmares 15y agoperformance: thanks, you are right. i read something right after posting. i think it was written by Paul Irish. thanks again for the performance tips. html5 data: those are the attributes that i was referring to in the beginning of the post.