Does jQuery do any kind of caching of “selectors”?

后端 未结 14 2166
挽巷
挽巷 2020-11-27 18:14

For example, will the first piece of code perform a full search twice, or is it smart enough to cache results if no DOM changes have occurred?

if ($(\"#navba         


        
14条回答
  •  迷失自我
    2020-11-27 18:48

    $.selectorCache() is useful:

    https://gist.github.com/jduhls/ceb7c5fdf2ae1fd2d613e1bab160e296

    Gist embed:

提交回复
热议问题