Here you’ll find some useful jQuery snippets for document loaded.

jQuery Document Ready

// Common method
jQuery( document ).ready( function() {} );

// Or, if no conflict
$( document ).ready( function() {} )

// Variant method
jQuery( document ).ready( your_function );

// Alternative method
jQuery( function() {  
    console.log( 'Document Ready!' );  
});

// Alternative method and jQuery $ context
jQuery( function( $ ) {  
    console.log( 'Document Ready!' );  
}); 

Javascript Class

/**
 * Description
 *
 * @class           $CLASS_NAME$
 * @author          =undo= <info@wpxtre.me>
 * @copyright       Copyright (C) 2012-$YEAR$ wpXtreme Inc. All Rights Reserved.
 * @date            $DATE_NOW$
 * @version         1.0.0
 *
 */  
 
jQuery( function ( $ )
{
  "use strict";
  
  window.$CLASS_NAME$ = (function ()
  {

    // This object
    var $t = {
      version : '1.0.0',
      init    : _init
    };

    /**
     * Return an instance of $CLASS_NAME$ object
     *
     * @return {}
     */
    function _init ()
    {
      // Your init here

      return $t;
    };

    return _init();

  })();

});

Replace $CLASS_NAME$

Use strict directive

(function(){
  "use strict";

  // Define your library strictly...
})();

You can find out more stric directive in the John Resig – ECMAScript 5 Strict Mode, JSON, and More page.

Tips

The following snippets issue the same effect

+function() { 
  console.log( 'Hello World'); 
}();

// or

(function() { 
  console.log( 'Hello World'); 
})();

// or

(function() { 
  console.log( 'Hello World'); 
}());

// or

+function( $ ) { 
  console.log( 'Hello World'); 
}( window.jQuery );

// or

(function( d, $ ) { 
  console.log( 'Hello World'); 
}( document, jQuery ));


As usual, please don’t hesitate to leave any questions or comments in the feed below, and I’ll aim to respond to each of them.