Allow Custom JS in Block

@jonroc the best way is to use WP hooks to ensure that the code runs at the correct time. For example, blocks are registered in the init hook with the default priority 10.

If you wish to run some code after all the blocks are registered use this in inc/custom.php:

add_action( 'init',function() {
    //do something
}, 100);

The priority parameter 100 causes this hook to be called at the end.

(posting the same to the linked topic)

2 Likes