12d ago

Console error in WordPress - Uncaught ReferenceError: rive is not defined

Hi there,

I'm having an issue with animations not loading for me at all around 80% of the time, 20% of the time they load great. The error I am having seems to suggest the rive.js file I'm loading from here - https://cdn.jsdelivr.net/npm/@rive-app/canvas@latest/rive.js isn't loading all of the time. So my question is: Is this the correct place to pull this rive.js file from? Has anyone else experienced this? How can I overcome the sporadic loading of this file to make the animations load correctly?

Thanks in advance

5 replies
C
+1
12d ago

Hi I do not know what the problem might be. I'm going to pass this information on to the developers to see how they can help you.

C
12d ago

Hi When this happens what errors are you seeing in networking tools (e.g., 404 for the URL)?

12d ago

It's very weird because there is no error on the network, rive.min.js looks like it's loading in ok, but in the console I get the error I have above "Uncaught ReferenceError: rive is not defined" and in the sources panel it says the issue with the section "new rive.Rive({})

12d ago

Could there be a race condition between loading the library and executing the code?
Could you try to wrap the code in "document.addEventListener("DOMContentLoaded", function(){}" to see if it fixes it?

12d ago

Yeah that's fixed the loading issues was it trying to execute before the DOM content had fully loaded. Thanks for all the help, it's very much appreciated