Adding a class to all images with a parent of a tag

JavaScript performance comparison

Test case created by James C

Preparation code

<script src="//"></script>


Preparation code output

Test runner

Warning! For accurate results, please disable Firebug before running the tests. (Why?)

Java applet disabled.

Testing in CCBot 2.0.0 / Other 0.0.0
Test Ops/sec
Vanilla JS - using for loop to search through images with 'a' parent
var images = document.getElementsByTagName('img');
    var imagesArray = [];
    for (var i=0; i<images.length; i++) {                               
        var elements = images[i];
        if (elements.parentNode="a") {
                elements.parentNode.className += " hide-link";
jQuery - using has class method and adding class

You can edit these tests or add even more tests to this page by appending /edit to the URL.