Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
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
Test name
Executions per second
A
452282336.0 Ops/sec
B
9537776.0 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 }