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

90
Views
Is there a performance enhancement to create dom elements native vs innerHTML?

Suppose I want to do this:

let el = document.getElementById("some_div");
el.innerHTML = "<div><h3>Hello There</h3><div>Hello World</div></div>";

Would it be better to write it as:

let outer_div = document.createElement("div");

let h3 = document.createElement("h3");

let inner_div = document.createElement("div");

let hello = document.createTextNode("Hello World");

inner_div.appendChild(hello);
outer_div.appendChild(h3);
outer_div.appendChild(inner_div);

Or does it not even matter coding wise in todays' environments?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

I suggest to use createElement. It is faster and more secure. Imagine you load user input directly into your DOM with innerHTML. This can be a nasty security hole.

about 4 years ago · Juan Pablo Isaza Report
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!