GithubHelp home page GithubHelp logo

piecioshka / innerhtml-vs-removechild-vs-remove Goto Github PK

View Code? Open in Web Editor NEW
2.0 1.0 0.0 5 KB

Comparison: innerHTML vs removeChild() vs remove()

Home Page: https://piecioshka.github.io/innerhtml-vs-removechild/

HTML 18.86% JavaScript 81.14%

innerhtml-vs-removechild-vs-remove's Introduction

innerhtml-vs-removechild-vs-remove

Comparison: innerHTML vs removeChild() vs remove()

Preview ๐ŸŽ‰

https://piecioshka.github.io/innerhtml-vs-removechild-vs-remove/

Test results

Code below is execute 100_000 times.

innerHTML:

$element.innerHTML = '';

removeChild():

while ($element.firstElementChild) {
  $element.removeChild($element.firstElementChild);
}

remove():

while ($element.firstElementChild) {
  $element.firstElementChild.remove();
}

Results:

[Element exists in DOM: innerHTML] 20 ms
[Element exists in DOM: removeChild()] 49 ms
[Element exists in DOM: remove()] 31 ms
[Element does not exists in DOM: innerHTML] 11 ms
[Element does not exists in DOM: removeChild()] 1 ms
[Element does not exists in DOM: remove()] 2 ms

License

The MIT License @ 2022

innerhtml-vs-removechild-vs-remove's People

Contributors

piecioshka avatar

Stargazers

Sambath Kumar Logakrishnan avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.