$.ready vs $(fn)
JavaScript performance comparison
Info
Is the implied function better or not?
Preparation code
<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js">
</script>
<script>
var doc = $(document);
</script>
Preparation code output
Test runner
Warning! For accurate results, please disable Firebug before running the tests. (Why?)
Java applet disabled.
| Test | Ops/sec | |
|---|---|---|
$(document).ready |
|
pending… |
$(fn) |
|
pending… |
Cached $(document) |
|
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:
- Revision 1: published by Aaron Powell
- Revision 2: published by Tan Nhu
4 comments
Why is $.ready in this test. It doesn't take a function as an argument.
Add another whereby Preparation is the same as internal $(fn) reference js doc = jQuery(document);
Iteration js doc.ready(fn)
@gbakernet - yeah having $.ready was a mistake, I misread what it did.
yeah $.ready was my mistake ... caching $(document) makes sense, not sure it is worth the extra key length though