The situation is when jQuery loads on the back page, but javascript, which relies on accessible jQuery, loads before jQuery is a fairly common script, especially if you practice the practice of approximating your scripts to </body> .
So basically I want to move from this:
<script> someFunctionThatUsesLateJQuery(){ [code that relies on jQuery] } </script> ... <script src="jquery.js"></script> <script> $(function(){ someFunctionThatUsesLateJQuery(); }); </script>
Something like that:
<script> _$.ready(function(){ [code that relies on jQuery] }); </script> ... <script src="jquery.js"></script>
Like tracking asynchronous statistics (Γ‘ la Google Analytics), is there anything that allows you to record javascript function calls that will be executed after jQuery loads without receiving the $ is undefined error?
I mean this will happen without registering and unregistering timeouts / intervals.
Is there ever the possibility of adding some kind of pre-registration variable to jQuery that it recognizes and processes after loading it?
Use case:
It is worth noting that the specific use case that I have is a JS-drop widget in which I want some DOM manipulations to occur on the <script> placement, which therefore has a very real possibility appears before jQuery is loaded into case jQuery loading around </body> .
Then I donβt want to burden the user anymore, requiring them to register a specific function call at the correct code execution point (which will depend on their implementation) ... I want it to just work
source share