Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6544929
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T11:31:28+00:00 2026-05-25T11:31:28+00:00

After my previous question I heve this one, that might be better. I need

  • 0

After my previous question I heve this one, that might be better.

I need to add a lot of items on the page and I see that sometimes appendChild+fregment is faster than innerHTML. Anyway now I would need to know the fastest way to add elements and add event listeners too.

One way I see is to listen on the window object and then filter.
Pros:

  • Only add once, then never
  • No memory trap if you forget to remove events listeners before remove as the event is added on the window object
  • others?

Cons:

  • Maybe slower?
  • Slower as we need to filter the items and will listen for everything everyime… maybe too slow at this point, I don’t know.

The other way I know is to listen on the created element.

But with innerHTML I think only works with the window object listener.

Any other oppinions?
thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T11:31:29+00:00Added an answer on May 25, 2026 at 11:31 am

    Best practice to handle “multiple” event handlers for “many” elements is event delegation, which is basically what you described.

    Create a listener on the closest shared parent (document.body will of course do it for any element, but maybe there is another parent node below that).

    Performance should not be the issue there. It’s far worse to create like 200 event handler functions instead of one.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This question depends my previous question: Browser crashes after 10-15 mins On that question
This is related question to my previous question but different one. After searching a
This is an error that came up after I got a previous question here
After considering the answers to my previous question ( One SVN Repository or many?
Hello every one this is extension to my previous question.Here is the link File
This question follows on from a previous question which can be found here: Need
After my previous question I have managed to Add and Ad banner to my
Please view my previous question here: Animate Divs One Right After the Other with
After my previous question of SavingToFile with TStringList , I now need to load
this is a follow up question from my previous one. you can find it

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.