How to check if jQuery user interface files are included?

I am using CMS on my website and have encountered a problem. CMS includes jQuery files on some pages, but not all, and I need to be able to use jQuery everywhere. I found a solution to enable the jQuery core library using the following code:

if(!window.jQuery) { document.write("<" + "script type='text/javascript' src='https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js'></" + "script>"); } 

However, I do not know how to check whether jQuery UI JS and CSS files were included or not, in particular these files:

 <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.23/jquery-ui.min.js"></script> <link rel="stylesheet" type="text/css" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css"> 

Is there a way to check if these files were included, similar to the above for the jQuery core library?

+4
source share
2 answers
 if(!jQuery.ui) { // Load Jquery UI here } 

Remember that you can use jQuery getScript () to load libraries ...

+4
source

Find the ui property of the jQuery object.

 if(!window.jQuery.ui) 
+3
source

All Articles