I wanted to check that jQuery has been loaded, I've found different approaches for that and wanted to see their differences, also to know which one may be better or would be best practice to use.
if (typeof jQuery != 'undefined') {
// jQuery has been loaded.
}
if (window.jQuery){
// jQuery has been loaded.
}
This one is the same as previous example but using window.onload, what's their difference at the run time?
window.onload = function() {
if (window.jQuery) {
// jQuery has been loaded.
}
}