I need the first load to solve the autoload problem of the scripts I do with php where I can not set the order in which they are going to be loaded, and after that I need to load that load into another load. Is it possible to use a load event inside another load event?
INDEX.HTML
<html>
<head>
...
</head>
<body>
...
<?php
$scripts = dir("js");
while ($script = $scripts->read()) if ($scripts != "." && $scripts != "..") echo "<script src='js/{$script}'></script>";
?>
</body>
</html>
Then I have the files carta.js, funcoes.js, script.js and texto.js. letter and text are classes, functions have a lot of functions that I use in the program and the script depends on these files already being read to work.
SCRIPT.JS
const cnv = document.getElementById("canvas");
cosnt ctx = cnv.getContext("2d");
const imgs = [];
for (let i = 0; i < 10; i++) {
(imgs[i] = new Image()).src = 'img/imagem${i}.png';
}
window.onload = () => {
// executa o resto
}