jquery - is there $(document).find('selector') and $('selector') difference -


i've started working on project , in code find combintions of $(document).find('selector') , $('selector'). cant find real reason why done. there significant differnece between 2 used simultaneously in project? should prefer 1 before in cases?

$(document).find("selector") , $("selector") match same set of elements.

there's no reason use $(document).find(...) on $(...), , several reasons not to:

  1. it's longer write , more awkward read, inflating script size

  2. it results in more memory churn (more temporary objects created/destroyed)

  3. it's slower - http://jsperf.com/vs-document-find, http://jsperf.com/selector-vs-find-again

enter image description here


Comments

Popular posts from this blog

java - Plugin org.apache.maven.plugins:maven-install-plugin:2.4 or one of its dependencies could not be resolved -

Round ImageView Android -

How can I utilize Yahoo Weather API in android -