I want to load jquery asynchronously on a page and then load an other script which depends on jquery (it executes jquery code when loaded). But how can I detect if jquery has finished lodading. Is there an event for this in jquery which fires when the library finished loading?
In theory I could load jquery like this:
<script async src="jquery.js" onload="jqueryloaded()"></script>
but I want the code to work on older browsers too which may not support the async and onload attributes. (In this case jquery is loaded synchronously.) That's why I'm looking for an event which jquery emits when it's loaded. Is there one?
window.jQuery
is present.<script>if (window.jQuery) jqueryloaded();</script>
Otherwise, don't use<script async
if you need to support all browsers. – cookie monsteronload
handler a single solution that works for both async/sync situations? The event should fire either way, right? – cookie monsterscript.onload
support. – cookie monster