There is no difference in functionality between your examples - they both bind to DOM ready.
For reference, there are two points at which you can bind your jQuery code.
The first will execute when the DOM is ready (both are equivalent):
$(document).ready(function() {
// code
});
$(function() {
// code
});
The second will execute when the page has finished loading all images, stylesheets etc.
$(window).on("load", function() {
// code
});
The second is useful when you need to get the width()
or height()
of an image. These properties are only available once the image has completely downloaded to the client system.
Also note that $(window).load(fn);
is now deprecated and should no longer be used.