简体   繁体   中英

Refreshing jQuery variable as selector vs re-using selector performance

我想知道如果在刷新一个jQuery变量作为一个选择之间的性能差异的任何像这样的 ,只是使用选择两次。

In the link you provided there is no functional difference. The only change is in the source of the selector string (hard-coded as opposed to derived from a property). In both cases the same selector string is run through jQuery.

Everyone's answer so far is true:

  1. The difference is negligible (see next point for proof)
  2. You can put them in a loop and try ( http://jsperf.com/selector-refresh-vs-new-selector )
  3. In both cases the selector string is the same
  4. The selector property is deprecated

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM