Define a sequence of document.ready () functions?

In old jquery, you can add a function to the top of the document. Here's how it is:

$.readyList.unshift(function () { 

Now it is impossible. Is there any other way to move one function to the beginning? Our ASP.NET pages are made up of different controls, all of which have their own document.ready, so it's currently impossible for me to change this. But I need one function to run in front of everyone else.

Is there another β€œclean” way to do this?

+4
source share
2 answers

from here :

This is due to the fact that the event is ready (and should be) - the fact that some of the internal organs were exposed was a mistake (the one we are working to correct). As you mentioned, this was undocumented and the impact was unintentional.

Although I'm not sure what is stopping you from writing your own list (or extending jquery) with new readyList:

 var readyList = [func1, func2, func3 ...]; 

and executing it one by one in .ready() :

+4
source

Use holdready .

from jQuery :

 $.holdReady(true); //your function that must be first... $.holdReady(false); 
+3
source

Source: https://habr.com/ru/post/1490280/


All Articles