Answer the question
In order to leave comments, you need to log in
Which code in theory will work faster?
There is a big project with connected jQuery for plugins. But the rest of the JS if written without using jQuery, will it give at least some performance boost?
Option 1
var doc = document,
link = doc.querySelector('.link');
link.addEventListener('click', function() {
this.classList.add('active');
});
var link = $('.link');
link.click(function() {
$(this).addClass('active');
});
Answer the question
In order to leave comments, you need to log in
Will it give any performance boost?
In this example, there will be an increase in speed, but it will be so minimal that it can be neglected. And in real code, the performance will most likely be even worse, because. jquery has a bunch of optimizations. More effort will be spent, and the code will be more difficult to maintain in the future. So there is no point in saving on matches in this case, and taking care of performance in bottlenecks. For example, when animating, rendering large lists, updating, etc.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question