Requete du DOM dans une boucle

Benchmark created on


Description

setTimeout → Notez que le passage de paramètres supplémentaires à la fonction dans la première syntaxe ne fonctionne pas dans Internet Explorer.

Preparation HTML

<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>

Setup

var elt = jQuery("h1:first");

Test runner

Ready to run.

Testing in
TestOps/sec
Sans cache
function move(i) {
    if (i < 10) { 
        jQuery("h1:first").eq(0);
        setTimeout(move, 100, i + 1);
    }
}

move(0);
ready
Avec cache
function move(i) {
    if (i < 10) { 
        elt.eq(0);
        setTimeout(move, 100, i + 1);
    }
}

move(0);
ready

Revisions

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