I've been reading a lot about jQuery.ready()
will slow your page down. My website has a bunch of code running inside jQuery.ready()
as many websites do.
</body>
<script>
jQuery(document).ready(function() {
// Do some event binding and initialization.
});
</script>
I place this script at the end of <body>
tag but I wrapped the code inside DOM ready
just to be safe.
Now I test my page with http://www.webpagetest.org/ and I noticed that the domContentLoaded
time is as follows:
domContentLoaded
4.987s - 5.317s (0.330s)
Now I experimented by removing jQuery.ready(function() {});
to be just
</body>
<script>
// Do some event binding and initialization.
</script>
And I test the page again. Here's the result.
domContentLoaded
3.772s - 3.915s (0.143s)
The execution goes down to just 0.1s which is about ~187ms
. Am I right to assume that the execution time goes down because the code is not executed inside jQuery.ready
and what does this mean in terms of performance gain, e.g perceived performance. Do users feel that the page loads quicker?