Can we use the DOMContentLoaded event inside an async function?

Hello guys, sorry to disturb you all; I tried to use the DOMContentLoaded event in an async function but it seems that the event isn't being executed, is there a reason for that please
3 Replies
LcsGa
LcsGa2w ago
Hey! Some of your awaited stuff in your async function may simply be done after the Dom content loaded You can try adding some console logs in that event, outside of the async func and one within and you would see which one comes first An event is missed if not listened in time
Faker
FakerOP2w ago
ah ok, like the thing is since it is in an asyn function, the DOMContentLoaded even is missed ? Like other things might happen before it ?
LcsGa
LcsGa2w ago
Like : - your async function is invoked but pending - the event is fired - after a blocking await resolves, you start listening to the event => Since the event firing is happening before starting to read it, you missed it
Want results from more Discord servers?
Add your server