Posted By

mike-tempest on 11/11/10


Tagged

javascript jquery alternative document no conflict ready conflicts


Versions (?)

Who likes this?

4 people have marked this snippet as a favorite

etiennecarre
mike-tempest
McWatt
Priestd09


Rather than using $(document).ready / alternative no conflict


 / Published in: jQuery
 

URL: http://www.michaeltempest.com

Hello,

I have been developing with jQuery for just over a year now, I thought I would share something with you that I have found pretty time saving over the past few months.

If you have ever had javascript conflicts due to several different javascript libraries being used you will understand the need for using this method.

Rather than using the documented $(document).ready method of starting any javascript functionality on document load. I recommend that you give the alternative shown below. This is due to the common conflict between Javascript libraries using the $ symbol. By writing your document ready in this way, any $ symbols within this declaration will be ignored by all other javascript libraries.

Meaning you will no longer need to use the no conflict method of solving the same problem

  1. jQuery(function( $ ){
  2. //Insert your javascript code here
  3.  
  4. });

Report this snippet  

You need to login to post a comment.