3 ms·
> The script attempted to modify a div's background color using document.body.removeChild, but as the script was loaded in the HTML head, the DOM had not loaded
by chrisjj 3y ago
> The script attempted to modify a div's background color using document.body.removeChild, but as the script was loaded in the HTML head, the DOM had not loaded yet and document.body was not available, causing the script error.
Don't we have computers to catch such faults?
- chopin 3y agoIsn't it best practice to wait for document.loaded before starting JavaScript shenanigans?
- chrisandchris 3y agoWell, that's web engineering basics 101: HTML/CSS/JS should be treated as sequential (line-by-line processed). Therefore, even linkting to JS before any HTML tag will result in no element being in the DOM (while the JS is called).
- hulitu 3y ago> Don't we have computers to catch such faults? We had some years ago. Now we have AI.