bind to ready and resize 1

JavaScript performance comparison

Test case created by ryanve

Info

http://stackoverflow.com/questions/8976092/bind-to-ready-and-resize-at-same-time-using-jquery-on

Preparation code

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

Preparation code output

Test runner

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

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
1
(function() {   
    var count = 1;
    function stuffForRezieAndReady(){
      $('#output').html( (count++) );
    }
    $(window).on("resize", stuffForRezieAndReady);
    $(document).on("ready", stuffForRezieAndReady);
})();
pending…
2
$(document).on('ready', function() {
    var count = 1;
    $(window).on('resize', function() {
        $('#output').html( (count++) );
    }).trigger('resize'); // Trigger resize handlers.
});//ready
pending…
3
(function() {   
    var count = 1;
    function stuffForRezieAndReady(){
      $('#output').html( (count++) );
    }
    $(window).on("resize", stuffForRezieAndReady);
    $(document).ready(stuffForRezieAndReady);
})();
pending…
4
$(document).ready(function() {
    var count = 1;
    $(window).on('resize', function() {
        $('#output').html( (count++) );
    }).trigger('resize'); // Trigger resize handlers.
});//ready
pending…

Compare results of other browsers

Revisions

You can edit these tests or add even more tests to this page by appending /edit to the URL. Here’s a list of current revisions for this page:

0 comments

Add a comment