Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

177
Views
Why event delegation in Javascript is faster from normal child event?

Why number one code, is a normal child event listener code in js is slower than number 2 code, number two is event delegation in js.

// #1
navLink.forEach(function (item) {
item.addEventListener('click', function (e) {
 e.preventDefault();
 const navId = item.getAttribute('href');
 const navEl = document.querySelector(navId);
 navEl.scrollIntoView({ behavior: 'smooth' });
});
});


// #2
navLinks.addEventListener('click', function (e) {
e.preventDefault();

// matching strategy
if (e.target.classList.contains('nav__link')) {
const navId = e.target.getAttribute('href');
const navEl = document.querySelector(navId);
navEl.scrollIntoView({ behavior: 'smooth' });
 }
});
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!