Saturday, October 22, 2022
HomeWordPress Developmentjavascript - The place to incorporate JS library in gutenberg blocks

javascript – The place to incorporate JS library in gutenberg blocks


Let’s imagine that I need to make a block with animations from an exterior library as GSAP.

I’ve this file construction (information not wanted omitted):

my-blocks-plugin
 │   └─ blocks
 │       └─ my-block-1
 │          ├─ block.json
 │          ├─ index.js
 │          ├─ edit.js
 │          └─ save.js
 │
 └───── package deal.json

my-theme
 │   └─ app.js (imported GSAP as a module)
 │
 └───── package deal.json (it consists of GSAP)

I’ve imported GSAP as a module in my theme inside my-theme/app.js for theme animations.

The primary query is, to be used GSAP in a block:

Ought to I exploit the GSAP within the theme? If sure, the plugin will likely be theme dependent.

Ought to I embody GSAP within the my-block-1/save.js?

If sure: It does not matter that the library is redundant with the theme’s library?

Additionally, will the library be loaded each time a block is included within the editor? (Many blocks = many redundant libraries)

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments