How to include assets properly (plugin)

Just one more question @matjaz . I just recognized that the javascript file get’s enqueued in the header (without passing the argument for it).

Although I can optimize that using an optimization plugin which moves the javascript to the footer again I would prefer to have either the option to select where to load it or to load it before the tag by default.

I’ve adapted the code, basically all you need to change is passing that last parameter in wp_enqueue_script() ($in_footer) with a Boolean-Value of True!

Another Approach would be to include enqueue scripts into the render_callback argument of the register_block_type function (found here: wp enqueue script - Load CSS/Javascript in frontend conditionally if block is used - WordPress Development Stack Exchange). That would theoretically solve the limitation of only one js and one css file for every block (in 99.99999% of all cases one would be enough for a block I guess, but just wanted to point that out too) :smiley:

I did a quick test and it didn’t work in first place, so maybe that doesn’t work anymore but probably I did something wrong!

And last but not least, is there a possibility to also get that 'editor-script' argument? I’ve also tested that and it worked for me when using the same script, if using another script you would probably have to run through the register_script process again and you would need to implement a control inside of pinegrow. That’s nothing which I consider as too important but I think it would be cool to have the ability to write the javascript also for the gutenberg-editor so you get a more live-editing experience! Maybe for any future update? :slight_smile: