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
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 spanHoo
Labels: javascript, jquery, js
0 Comments:
Post a Comment
<< Home