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 7080949
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T06:51:29+00:00 2026-05-28T06:51:29+00:00

Well I use a script that get a external JSON from a file, and

  • 0

Well I use a script that get a external JSON from a file, and loop thru its objects and creates the HTML on a string then after all is done, it appends in the DOM. But I would like to know if it’s better to use for example: onclick html attribute (directly into the code) or add an event listener to all html objects by its classes at once with JavaScript after appending to the DOM.

Is it the same speed or one is faster than the other and why?
I use a lot of HTML objects so I really need to know that, to get the best performance of it.

  • 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-28T06:51:29+00:00Added an answer on May 28, 2026 at 6:51 am

    I would suggest using some simple event delegation:

    // works on existing and future elements
    // since we are attaching to the parent
    var d = document;
    d.getElementById("theParentOfAppendedElements").onclick = function (e) {
        if(e.target.tagName.toLowerCase() === "something" 
            && e.target.className === "appended") {
            // do something
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have written a few MSBuild custom tasks that work well and are use
Well, for integers I would use NSNumber . But YES and NO aren't objects,
In this xkcd comic : they mention that real programmers use cat . Well,
I wanted to write a small script that searched for an exact file name,
I am trying to modify a batch script that installs a simple script file
I'm struggling to design the server-side script that responds to requests from an Ajax
I wrote a bash script that fetches lyrics from a website. The script is
I have a large SQL script that creates my database (multiple tables, triggers, and
I use Eclipse with ant scripts, and Eclipse works well with the default JRE
Requirements: Must be able to use C strings as well as C++ strings Fast

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.