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

  • Home
  • SEARCH
  • 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 6103235
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T13:42:21+00:00 2026-05-23T13:42:21+00:00

I have 464 JSON objects. An HTML element needs to be generated from each

  • 0

I have 464 JSON objects. An HTML element needs to be generated from each of these elements, and inserted into a div in sequential order. What’s going to be the fastest way to render this?

A) Loop through the objects, generating markup for each, concatenating them all, and setting the innerHTML of the container div to the concatenated markup:

document.getElementById("container").innerHTML = 
    jsonItems.map(function(item) {
        return convertToHTMLString(item);
    }).join("");

B) Loop through the objects, generating a DOM node for each, and inserting each sequentially into container:

var container = document.getElementById("container");

jsonItems.forEach(function(item) {
    container.appendChild(convertToDOMNode(item));
});

C) Loop through the objects, generating a DOM node for each, sequentially appending them to a DocumentFragment, then inserting the fragment into the container:

var fragment = document.createDocumentFragment();

jsonItems.forEach(function(item) {
    fragment.appendChild(convertToDOMNode(item));
});

document.getElementById("container").appendChild(fragment);
  • 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-23T13:42:21+00:00Added an answer on May 23, 2026 at 1:42 pm

    Benchmark

    The correct answer is please benchmark it yourself 🙂

    I personally think .innerHTML is the devil so use document fragments.

    And I think we all know document fragments are superior to injecting data directly into the DOM. It’s the exact same logic as rendering stuff off the screen then swapping it back in.

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

Sidebar

Related Questions

Have you refactored from an ActiveRecord to a DataMapper pattern? What conditions prompted the
I have been reading up on porting ASP.NET Membership Provider into .NET 3.5 using
Have I correctly added an element to a hashTable? Flows flows = new Flows(sIP,dIP);
I have a project that adds elements to an AutoCad drawing. I noticed that
I have an issue when I try to use datagrid.items.add() to add items from
Have just started to get into CakePHP since a couple of weeks back. I
have different files with same name, in different directories. In these files there are
Have a flash player that pops out into a separate popup browser window. And
Have this result set below; am trying to insert the red numbers into post_position
have been able to output images from BLOB, however I am now wanting to

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.