Load order of userscripts
Is it possible to somehow influence the order the userscripts are loaded. I have a userscript which depends on another.
I tried naming the userscript files in the alphabetical order I need them to be loaded but that did not help.
Any ideas?
Thanks
Rob
3 Answers
-
try to add an eventlistener with a load function. Im not sure this will work, biut its worth giving it a try.
e.g.
function loadScript1() { // do stuff } function loadScript2() { // do stuff } function loadScript3() { // do stuff } loadScript1(); loadScript1.addEventListener('load', function() { loadscript2(); }); loadScript2.addEventListener('load', function() { loadScript3(); });
-
I will give it a try. Thanks.
-
Using functions and appropriate listeners to call the function at your designated moment may help.
Approach:
Encapsulate related actions into functions.
Call only when necessary.Note: Make sure your variables are global (outside functions) if you want to use them in other places…