ahmadawais/create-guten-block

What's the work flow for including js libraries in a block?

yangkennyk opened this issue · 1 comments

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.