Hello,
Is there a way to enqueue script in <head> when a block is used:
I’m using :
acf_register_block_type( array(
...
wp_enqueue_script('myscipt-js', plugins_url( '/js/myscript.js' , __FILE__ ), '2.1.0', false);
...
));
Even with the parameter $in_footer to false… I can’t manage to have in the head … Always in the footer.
Any ideas?
Ty
Yes indeed, if you are using the updated Block method for ACF Pro that uses the WordPress block.json then everything block.json can do you can now do too.
"editorScript": "file:./index.js",
"script": "file:./script.js",
"viewScript": [ "file:./view.js", "example-shared-view-script" ],
https://developer.wordpress.org/block-editor/reference-guides/block-api/block-metadata/
YES …
Thank you very much!
I did manage to have the script in the head with this method!