jQuery document-ready event jQuery 3.0



As of jQuery 3.0, only this form is recommended:

jQuery(function($) {
  // Run when document is ready
  // $ (first argument) will be internal reference to jQuery
  // Never rely on $ being a reference to jQuery in the global namespace

All other document-ready handlers are deprecated in jQuery 3.0.


As of jQuery 3.0, the ready handler will always be called asynchronously. This means that in the code below, the log 'outside handler' will always be displayed first, regardless whether the document was ready at the point of execution.

$(function() {
  console.log("inside handler");
console.log("outside handler");

> outside handler
> inside handler