Jquery vs .find () context selector

Which is more efficient?

var container = $("#container"); // 1 var links1 = container.find("a"); // 2 var links2 = $("a", container); 

I personally prefer $("a", container) because it looks better, but are they different from performance?

+6
source share
1 answer

The context selector $("a", container) converted to find. find() will be faster, but in most cases this can be ignored. I would go for find() , as its syntax is pretty simple for me. This post has a performance comparison that will help you decide which one you will use.

+8
source

Source: https://habr.com/ru/post/951693/


All Articles