How to make a script load after Custom Block is loaded in the editor?

I’m trying to make a Custom Gutenberg Block, but I’m having trouble with loading javascript that goes with this block.

On the front-end it works fine, but in the editor it seems that the script fires (even with DOMcontentloaded or window.onload) BEFORE the Gutenberg block itself is fully loaded.

Since my script targets an element in the block (which it can’t find because the element hasn’t loaded yet), it’s not working correctly.

Any suggestions on how to make the script load AFTER the Custom Block has loaded fully in the editor?

(I’m using the ACF way of creating Custom blocks)

Read more here:: How to make a script load after Custom Block is loaded in the editor?

Leave a Reply

Your email address will not be published. Required fields are marked *