jQuery shorthand for the document ready wrapper function

This post is over 3 years old, so please keep in mind that some of its content might not be relevant anymore.

If you use jQuery you know that, if you want the DOM to be ready before firing a jQuery/javascript function, you need to wrap your code in the “document ready” function like this:

$(document).ready(function() {
  //some js code
});

If you prefer, you can use a shorthand:

$(function() {
  //some js code
});

Enjoy!

Leave a Reply

Your email address will not be published. Required fields are marked *