Integrating a js library into a block

I aim to integrate an animation library (gsap) into a Gutenberg block to render both in the frontend and the editor. While I successfully imported gsap into view.js for frontend rendering, I encountered difficulties achieving the same effect in the editor. Despite attempting to import gsap into edit.js and wrapping the animation script within a DOMContentLoaded event listener, I have not achieved the desired outcome. I also tried importing gsap in both editor.js and index.js and then setting the “script” key in block.json to point to the animation script (gsap).


This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer