It is document ready handler
$( document ).ready(function() {
// Handler for .ready() called.
});
This is to prevent any jQuery code from running before the document is finished loading (is ready).
is equivalent to
$(function() {
// Handler for .ready() called.
});
If .ready() is called after the DOM has been initialized, the new handler passed in will be executed immediately.
Here are some examples of actions that can fail if methods are run before the document is fully loaded:
1.Trying to hide an element that is not created yet
2.Trying to get the size of an image that is not loaded yet
The jQuery team has created an shorter method for the document ready event:
$(function(){
// jQuery methods go here...
});
It is depend upon the developers which syntax is to be used but document ready event is easier to understand when reading the code
For more details : See