/* Begining of jQuery cookie part 1 */ /* End of jQuery cookie part 1 */

Srini's Blog

Wednesday, May 07, 2008

To jQuery or not to jQuery?

Its interesting to see how one handles multiple jQuery includes.
If jQuery is already included in a page and you dont want to include "your own" jQuery file too, you have to do a bit of woodoo, as below..

You have to basically check if javascript thinks the variable "jQuery" is present or not.. Check here if this page has jQuery or not

< script type="text/javascript" >
if (typeof jQuery == 'undefined') {
console.log("Including jQuery dynamically");
document.write('< SCRIPT LANGUAGE="JavaScript1.1" SRC="jquery-latest.pack.js">');
document.write('<\/script>');
} else {
console.log("jQuery already present. Not including");
}
< /script >

< script >
$(document).ready(function() {
alert("jQuery");
$('span').hide("slow");
});
< /script >

Hello world



inline span

Hoo

Labels: , ,

0 Comments:

Post a Comment

<< Home