Listeners for load
events can be asynchronous and will be awaited. Listeners
for unload
events need to be synchronous. Both events cannot be cancelled.
main.ts
A couple notes on this example:
In other words, you can use addEventListener
to register multiple "load"
or
"unload"
event handlers, but only the last loaded onload
or onunload
event
handlers will be executed. It is preferable to use addEventListener
when
possible for this reason.