Toggle navigation
MeasureThat
.net
Create a benchmark
Tools
Feedback
Feature Requests
FAQ
Register
Log In
Run results for:
Testing both ways to run conditions on getAttribute from a Node
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:124.0) Gecko/20100101 Firefox/124.0
Browser:
Firefox 124
Operating system:
Ubuntu
Device Platform:
Desktop
Date tested:
2 years ago
Benchmark engine:
Benchmark.js
A
452.3M/s
B
9.5M/s
View exact numbers
Test name
Executions per second
✓
A
452,282,336 Ops/sec
B
9,537,776 Ops/sec
HTML Preparation code:
<div id="test" data-media-type="gifv"> lorem ipsum </div>
Script Preparation code:
localName = 'img'; parentNode = document.getElementById('test');
Tests:
A
if (localName === "img" && (parentNode.getAttribute("data-media-type") === "video" || parentNode.getAttribute("data-media-type") === "gifv")) { // do stuff }
B
if (localName === "img" && ["video", "gifv"].includes(parentNode.getAttribute("data-media-type"))) { // do stuff }