Does jQuery $(this) need to be cached

后端 未结 6 634
一生所求
一生所求 2021-01-13 14:05

I recently came accross some blog posts about jQuery performance (i.e. http://net.tutsplus.com/tutorials/javascript-ajax/10-ways-to-instantly-increase-your-jquery-performanc

6条回答
  •  心在旅途
    2021-01-13 14:29

    Well, there's a performance cost to executing the function, running through the init logic and returning an object, albeit probably a very small performance cost, so in this particular case, the need to cache is probably not significant.

    However, for the sake of code conformity, it is a good idea to cache objects that you use more than once as in other circumstances the performance difference can be significant, therefore getting into the habit is a good thing.

提交回复
热议问题