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:
it's longer write , more awkward read, inflating script size
it results in more memory churn (more temporary objects created/destroyed)
it's slower - http://jsperf.com/vs-document-find, http://jsperf.com/selector-vs-find-again

Comments
Post a Comment