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


/ Published in: jQuery
Save to your folder(s)

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


Copy this code and paste it in your HTML
  1. jQuery(function( $ ){
  2. //Insert your javascript code here
  3.  
  4. });

URL: http://www.michaeltempest.com

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.