Is jQuery loaded differently on the Order Status page? I’ve been doing some script tests and I notice that window.jQuery is not available at window.onload but if I wait a second it is available. Obviously I would prefer to not run scripts on a timer but I’m making an ajax API call so I would really like to use jQuery if possible. Using the setTimeout method I have no problem making the API call.
Example:
The following script will return “jQuery not loaded” when the Order page loads.
window.onload = function() {
if (window.jQuery) {
// jQuery is loaded
console.log("jQuery loaded")
} else {
// jQuery is not loaded
console.log("jQuery not loaded")
}
}
But if I wait 1 second after page load the same script returns “jQuery loaded”:
setTimeout(function() {
window.onload = function() {
if (window.jQuery) {
// jQuery is loaded
console.log("jQuery loaded")
} else {
// jQuery is not loaded
console.log("jQuery not loaded")
}
}
}, 1000)