create-guten-block icon indicating copy to clipboard operation
create-guten-block copied to clipboard

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

Open yangkennyk opened this issue 5 years ago • 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?

yangkennyk avatar Jan 23 '20 19:01 yangkennyk

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.

michaelslevy avatar Mar 06 '20 13:03 michaelslevy