create-guten-block
create-guten-block copied to clipboard
What's the work flow for including js libraries in a block?
I'm new to creating gutenberg blocks and react (so still learning!)
If I needed a js library for example like https://kenwheeler.github.io/slick/ in my block.
Should the initialization etc be included in the block or should it be a separate file?
If it's a separate file, how would I be able to optimize so that the library is only loaded if the block is used on a page?
You'd enqueue the JS and CSS in the init.plugin file. Then add the markup in the block JS file. You'd need to make a nested block to add the slides.