bigbuffet-rw/src/ready.ts
marcin mikołajczak cb3a900d39 exports?
Signed-off-by: marcin mikołajczak <git@mkljczk.pl>
2024-05-13 19:00:42 +02:00

9 lines
No EOL
233 B
TypeScript

const ready = (loaded: () => void): void => {
if (['interactive', 'complete'].includes(document.readyState)) {
loaded();
} else {
document.addEventListener('DOMContentLoaded', loaded);
}
};
export { ready as default };