1
I need the first load to solve the autoload problem of the scripts I do with php where I cannot define the order in which they will be loaded, and after that I need to load another load. You can use a load event within 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>
There I have the letter.js, funcoes.js, script.js and text.js files. letter and text are classes, functions have a lot of functions that I use in the program and the script depends on those files are already 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
}
Can you show the code you have? so we can find another solution that is more suitable
– Sergio
Okay, I’ll edit it out.
– Morais Vilson