I want to add a preloader to my website untill the website is fully loaded images, js, fonts everything but I'm confused which should I use
window.addEventListener('DOMContentLoaded', () => {
// code
});
or
window.addEventListener('load', () => {
// code
});
And if I used load or DOMContentLoaded
should I stop using defer for my script files?
And also if I have imported modules should it be outside the event? For example:
import { gsap } from "gsap";
window.addEventListener('DOMContentLoaded', () => {
// code
});
question from:
https://stackoverflow.com/questions/65830873/should-preloader-be-inside-domcontentloaded-or-load-event 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…