How to check if jquery is loaded in your theme or site.Well Answer is simple view the source code of your page.
But as a developer you want to check if jquery is loaded if it is not then it must load the jquery there is no dynamic script except javascript.
Also I’m introducing the jquery testing tool to test if jquery loaded. You can test online if the site is using jQuery or not so here is the tool.
Now lets come to the code simple code for jquery detection is :
|
1 2 3 4 5 6 |
if (typeof jQuery != 'undefined') { // jQuery library is loaded //alert("jQuery library is loaded"); }else{ alert (jQuery library is not inluded); } |
But this code can only check if jQuery is loaded or not.But we want that if jQuery is not loaded then load it.
Now lets do some tweak with code:
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
if (typeof jQuery != 'undefined') { }else{ var head = document.getElementsByTagName("head")[0]; script = document.createElement('script'); script.id = 'jQuery'; script.type = 'text/javascript'; script.src = '//ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js'; head.appendChild(script); } |
Well this code will not work in every case.
If the above code works well then its ok otherwise proceed further.
Now we have to introduce some kind of popup or alert.
Until the user press ok jquery will loaded in the head of your page.
I’m using the following code for my plugin JinMenu
So the code below may works in every case.
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
if (typeof jQuery != 'undefined') { }else{ var head = document.getElementsByTagName("head")[0]; script = document.createElement('script'); script.id = 'jQuery'; script.type = 'text/javascript'; script.src = '//ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js'; head.appendChild(script); alert("Jin Menu unable to detect jquery\nAutoloading...\nDone !!!!"); } |
Incoming search terms:
- jquery
- check if jquery is loaded
- wordpress test if jquery is loaded
- detect jquery loaded javascript
- javascript check if jquery loaded
- jquery images
- tool to test jquery loading
- var is_loaded=0;
- check if jquery loaded
- c# check if jquery loaded
- check if jquery lib i sloaded
- check if image is loaded jquery
- jquery if loaded then
- joomla how to test jquery loaded and working
- jquery detect if ui is loaded
- jquery check if jquery is loaded else load it
- jquery and detect loaded
- jquery ajax load if else
- joomla jquery is undefined
- jquery loaded but undefined
- jquery loading
- wordpress loading jquery
- wordpress google jquery library youtube


