Scripts no longer work in block editor.
-
I have a few custom blocks that use Javascript to render data on the front-end. Because of this, I was able to render this data in the block editor with the following code:
/** * Enqueues custom scripts for the block editor. */ function blacklab_block_editor_enqueue() { wp_register_script('blacklab-scripts', get_template_directory_uri() . '/assets/js/public/blacklab.min.js', array('jquery'), '3.6.6', true); wp_localize_script('blacklab-scripts', 'localVar', blacklab_localized_variables()); wp_enqueue_script('blacklab-scripts'); wp_enqueue_script('fontawesome', 'https://kit.fontawesome.com/1fd309c3ea.js', '', '', false); } add_action('enqueue_block_editor_assets', 'blacklab_block_editor_enqueue');
However, after upgrading to WordPress 5.9, the Javascript no longer executes properly in the block editor. It used to work just fine. I have all my JS combined into one file so I don’t have to separate it out across tons of files for various small blocks. I don’t see anywhere in the notes to mention a change or what is supposed to be done to make this work now.
The documentation still says to use this:
https://developer.www.ads-software.com/block-editor/how-to-guides/javascript/loading-javascript/Can someone please help me resolve this issue?
- The topic ‘Scripts no longer work in block editor.’ is closed to new replies.