jQuery noConflict wrappers on WordPress

WordPress is a wonderful publishing platform with many JavaSript Framework including jQuery. Until today jQuery is one of my favorite JavaScript libraries, it’s more easy, there are a lot of plugins available and I have a wonderful jQuery guru ;)

Some problem on jQuery and other JavaScript library is, conflict between this library. To eliminate this problem, jQuery has method by added some code jQuery.noConflict(); and don’t worry, WordPress has been added some tricksand added this featured too, using jQuery with other libraries in WordPress is easy, all need to do just write your JavaScript Code like on this example

1
2
3
jQuery(document).ready(function($) {
    // $() will work as an alias for jQuery() inside of this function
});

That wrapper will cause your code to be executed when the page finishes loading, and the $ will work for calling jQuery. If, for some reason, you want your code to execute immediately (instead of waiting for the DOM ready event), then you can use this wrapper method instead:

1
2
3
(function($) {
    // $() will work as an alias for jQuery() inside of this function
})(jQuery);

I hope this tricks for using jQuery on WordPress working great on your blogs and you didn’t found any problem on it.