Reputation: 805
We have some restrictions on the CMS we are using and the jQuery code is included in the footer of the page.
We use the code below to determine if jquery is available, however as jQuery is loaded after this script is included this always returns false resulting in our code not being executed.
if (typeof jQuery != 'undefined') {
Is it possible to force this to wait until full page load without using:
jQuery(document).ready(function($) {
Note: We are unable to move the jQuery code higher in the source and even implementing something like the below is probably not possible given the way the CMS is setup. (Very limited access to template files).
Load jQuery after DOM, how can I make $.ready() available to my page before jQuery is loaded?
Upvotes: 0
Views: 70
Reputation: 36531
have you tried this ...
The DOMContentLoaded event is fired when the document has been completely loaded and parsed, without waiting for stylesheets, images, and subframes to finish loading (the load event can be used to detect a fully-loaded page).
document.addEventListener('DOMContentLoaded',function(){ //codes })
Upvotes: 1
Reputation: 1115
You can do the following with the HTML code
<body onlaod="checkjquery()">
And you would define that function as you wish
Upvotes: 0