<script src="https://cdnjs.cloudflare.com/ajax/libs/blissfuljs/1.0.6/bliss.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/umbrellajs"></script>
<div id="foo">Hello World</div>
var text = document.getElementById("foo");
var text = document.querySelector("#foo");
var text = document.querySelectorAll("#foo");
var text = document.getElementById("foo").textContent;
var text = document.getElementById("foo").innerHTML;
var text = Bliss("#foo");
var text = Bliss("#foo").textContent;
var text = Bliss("#foo").htmlContent;
var text = u("#foo");
var text = u("#foo").text();
var text = u("#foo").html();
--enable-precise-memory-info
flag.
Test case name | Result |
---|---|
Vanilla Get ID | |
Vanilla Get ID (QuerySelector) | |
Vanilla Get ID (QuerySelectorAll) | |
Vanilla Get Text | |
Vanilla Get HTML | |
Bliss Get ID | |
Bliss Get Text | |
Bliss Get HTML | |
Umbrella Get ID | |
Umbrella Get Text | |
Umbrella Get HTML |
Test name | Executions per second |
---|---|
Vanilla Get ID | 3031956.5 Ops/sec |
Vanilla Get ID (QuerySelector) | 2039074.6 Ops/sec |
Vanilla Get ID (QuerySelectorAll) | 1136777.4 Ops/sec |
Vanilla Get Text | 2350545.8 Ops/sec |
Vanilla Get HTML | 2084128.6 Ops/sec |
Bliss Get ID | 1527621.9 Ops/sec |
Bliss Get Text | 1337336.1 Ops/sec |
Bliss Get HTML | 1559909.2 Ops/sec |
Umbrella Get ID | 353167.5 Ops/sec |
Umbrella Get Text | 337494.5 Ops/sec |
Umbrella Get HTML | 316966.5 Ops/sec |
Benchmark Overview
The provided JSON represents a JavaScript microbenchmark test suite, specifically designed to compare the performance of different methods for accessing and manipulating HTML elements in a web page.
Test Cases
There are eight test cases:
document.getElementById()
.document.querySelector()
with the #
selector.document.querySelectorAll()
with the #
selector.element.textContent
.Performance Results
The test results show the execution time (in seconds) for each test case across multiple browser runs. The fastest execution times are listed first.
Comparison and Insights
document.getElementById()
and document.querySelector()
with the #
selector tend to be faster than the other methods, likely due to their simplicity and efficiency.Conclusion
This benchmark helps evaluate the performance of different approaches for accessing and manipulating HTML elements in a web page. It suggests that Vanilla methods are generally faster, while Bliss.js and Umbrella.js have specific strengths and weaknesses depending on the use case.
Keep in mind that this is just one example of a microbenchmark test suite, and there may be other factors to consider when choosing a method for accessing and manipulating HTML elements.