JSFiddle - React, Tailwind, and code Playground
JavaScript
var ordem = [0,2,3,1]; // Especifica a ordem desejada
var iniciadores = []; // Acumula os iniciadores
$(document).ready(function() {
// Executa os iniciadores na ordem
for ( var i = 0 ; i < ordem.length ; i++ ) {
var x = iniciadores[ordem[i]];
x[0].apply(x[1], x[2]);
}
// Remove o "monkey patch"
$.fn.ready = oldReady;
});
var oldReady = $.fn.ready; // Guarda o ready original
// Monkey patch
$.fn.ready = function(fn) {
if ( this[0] == document ) // Se for no document...
iniciadores.push([fn, this, arguments]); // não execute, acumule
else
return oldReady.apply(this, arguments); // Senão execute
}
////////////// Teste ////////////////////
$(document).ready(function () {
console.log(1);
});
$(document).ready(function () {
console.log(4);
});
$(document).ready(function () {
console.log(2);
});
$(document).ready(function () {
console.log(3);
});