githubEdit

πŸ€How to add a GSAP animation

Add GSAP animations to your Webstudio site with custom code.

Embed GSAP library on the page

  1. Add HTML Embed Component to the canvas

  2. Activate "Client Only" setting

  3. Optionally activate "Run script on canvas" setting

  4. Copy the scripts into HTML Embed Code in Settings

Example

Q&A

How to reuse the animation on multiple pages?

You can reuse the animation using Slot component

Can I use the Custom Code from project settings to include GSAP on all pages?

While you can add the library in the HEAD in project settings, this HTML won't run in preview, so you can't test inside the builder. Additionally, if you use async or defer attributes, there is no guarantee that your HTML Embed scripts on the page won't run before the library is loaded. If you don't use defer or async attributes, you will slow down your site by blocking the rendering until the library is loaded.

Identifier 'x' has already been declared

Learn more about script scope here.

Demo

Preview Linkarrow-up-right Builder Linkarrow-up-right

  • Animations – Built-in animation capabilities in Webstudio

  • HTML Embed – Add custom scripts and code to your pages

  • Project Settings – Add global scripts in the custom code section

  • Variables – Use variables for dynamic animation values

Last updated

Was this helpful?