/ Published in: JavaScript
1) if jQuery is already loaded into a browsers' cache -> do nothing
2) if the object is undefined, write a script-element into the source which references google's minified jquery file.
3) if jQuery is still undefined (let's assume Google is down). write a script reference to our local copy into the source.
You could also use the if statements to define different JS files for the frontend and the backend.
(as seen on www.ie6update.com)
2) if the object is undefined, write a script-element into the source which references google's minified jquery file.
3) if jQuery is still undefined (let's assume Google is down). write a script reference to our local copy into the source.
You could also use the if statements to define different JS files for the frontend and the backend.
(as seen on www.ie6update.com)
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
<script type="text/javascript"> /* only load jQuery if not present */ if(typeof jQuery == 'undefined') { document.write("<script type=\"text/javascript\" src=\"http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js\"></"+"script>"); var __noconflict = true; } </script> <script type="text/javascript"> /* if Google is down */ if(typeof jQuery == 'undefined') { document.write("<script type=\"text/javascript\" src=\"/lib/js/jquery.min.js\"></"+"script>"); var __noconflict = true; } </script> <script type="text/javascript" src="/lib/js/functions.js"></script>