How to determine if jquery enabled webpage is enabled?

What is the best way to determine if a web page is included in jquery? Using jquery itself if this is the best way to define it.

+4
source share
6 answers
if(jQuery) //jquery object exists 

jQuery is not magic - it is essentially just a big object. You can check it, like any other object.

The same goes for providing library loading in jQuery:

 if(jQuery.DatePicker) //lib exists 
+9
source

The best way to check if jQuery is loaded,

 if (window.jQuery) { // jQuery is loaded } else { // jQuery is not loaded } 

If you checked the use of if(jQuery){} and it is not there, you will receive a control error, as shown below, and it will break the execution of your script . Checking if the window object has a jQuery property, if it does not exist, it simply returns undefined.

enter image description here

+6
source

Check javascript if jquery object exists.

Use the condition below if if to check if a jQuery object exists.

 if(jQuery) { //jquery object exists } 
+2
source

do a check to check if the javascript object is initialized.

 if(jQuery) { alert('jquery active'); } 
+1
source

Run this in the console:

 if (window.jQuery) { console.log("Yes there jQuery!"); } else { console.log("Nope, it not on this site..."); }; 
+1
source

if (jQuery) { // yup it there }

0
source

Source: https://habr.com/ru/post/1387954/


All Articles