Skip to content

Instantly share code, notes, and snippets.

@firestar300
Last active May 24, 2022 08:17
Show Gist options
  • Save firestar300/d145a55145965606f523498aaef937c2 to your computer and use it in GitHub Desktop.
Save firestar300/d145a55145965606f523498aaef937c2 to your computer and use it in GitHub Desktop.
Check if WordPress Gutenberg Block Editor is ready
const { select, subscribe } = wp.data;
const closeListener = subscribe( () => {
const isReady = select( 'core/editor' ).__unstableIsEditorReady();
if ( ! isReady ) {
// Editor not ready.
return;
}
// Close the listener as soon as we know we are ready to avoid an infinite loop.
closeListener();
// Your code is placed after this comment, once the editor is ready.
alert( 'is ready' );
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment