rive-app / rive-react

React runtime for Rive

Home Page:https://rive-app.github.io/rive-react

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

.riv file lazy loading

vannyle opened this issue · comments

Hi, I have several rive animations on one page. I'm wondering if it is possible to lazy load a .riv file to boost the web performance?

Hi @vannyle , you might find this example project useful to check out!
https://github.com/PaulieScanlon/rise-of-the-robots/blob/main/src/sections/gatsby-section.js#L9

^^ In the above, they lazy load the React component that uses useRive.

https://github.com/PaulieScanlon/rise-of-the-robots/blob/main/src/robots/gatsby-bot.js

This should help cut down on JS loaded in initially

Hi @zplata, thanks a lot for the useful example. I will definitely try it.