/** * Run a callback once the DOM is parsed. * * Replaces `@wordpress/dom-ready`. Same two cases WordPress handles: if the document has already * finished parsing, run now; otherwise wait for DOMContentLoaded. */ export const domReady = (callback: () => void): void => { if (document.readyState === "complete" || document.readyState === "interactive") { callback(); return; } document.addEventListener("DOMContentLoaded", callback); }; export default domReady;