Test for jQuery - RapidWeaver

language: HTML
license: Other

Code for Snippet:

                
/*
I wrote this version of the function test as an example for Joe Workman.
It will allow Stacks developers to test for jQuery/Mootools/js plugins/functions
prior to initiating their own version. This will save on HTTP requests and load times.
 
It also includes a fool proof way to include the new libraries in a RapidWeaver
file, a function I already include in most themes. It's called the
include() function. Since I make use of it already, I test for it here before
defining it again.
*/
 
if(!(typeof include == 'function')){// test for include() function
	function include(script_filename) {
		document.write('<' + 'script');document.write(' language="javascript"');document.write(' type="text/javascript"');document.write(' src="' + script_filename + '">');document.write('</' + 'script' + '>');
	}
}
if (typeof jQuery == 'undefined') {// test for jQuery. Change function name to suit.
	include('%assetPath%/jquery.js');// if not, we'll call it.
}
comments powered by Disqus

Info

Link to this snippet:


Download to Code Collector

To use the direct link to your snippet on CodeCollector.net either copy the html from the above section or drag the Download to Code Collector to where you would like to use it.

More Info:

Times Viewed: 787
Date Added: 2010-03-11 18:36:53
Last Modified: 0000-00-00 00:00:00

Web Analytics