UNPKG

bigpipe-util

Version:

This library currently implements small part of Facebook BigPipe so far, but the advantage is to efficiently insert/replace content and work with the DOM. It is also possible to easily call JavaScript modules from PHP.

14 lines (11 loc) 304 B
import EventListener from 'fbjs/lib/EventListener'; export default function onAfterLoad(callback) { if (document.readyState === 'complete') { setTimeout(callback, 0); } else { const event = EventListener.capture(window, 'load', () => { event.remove(); callback(); }); } }