Using Lottie Animation

Hello
Lottie is a player that is able to show animated SVG’s in any website, by importing a single javascript script.
Here’s an example with two lines of code that really work when using an HTML component on wix:
https://lottiefiles.com/web-player

The problem is - I don’t want to import the script on every HTML component I create on my website.
Is there a way to import that once and then use it in my HTML components across the website?

Hello,

If you want to use the same HTML component on several pages, you could either copy the element or set it to be Shown on all pages and hide() it on the certain pages.

Here you can find the API reference that shows you how to work with the HtmlComponent through code.

You can also contact Wix Support and they will assist you regarding Editor functionality.
https://support.wix.com/en/article/contacting-wix-support

Thanks, but I think I was misunderstood.
I was asking about the Lottie script that the HTML component needs to load - I don’t want it to be loaded on every component I use Lottie.
Is there a way around that?

You should contact LottieFiles support regarding this issue.

@yisrael-wix Thanks, but it’s not their problem.
Let’s generalize the question:
I want to be able to use an external script in my html components, without having to load that script every time on each component.
How can I do that?

@guyman20 I understood the question. What you want to do is to host someone else’s script on Wix, which is not supported. You can check with Lottie Files to see if they have an idea to help you.

@yisrael-wix I was unable to find a way to contact Lottiefiles.
I’ll still wait for someone here to come up with an idea to solve that.
Thanks

@guyman20
Not that hard to find how to contact them, they even have their own community that you can post too.

Just check their own website.

See this page here which tells you why Wix doesn’t provide support for third party code.
https://support.wix.com/en/article/using-iframes-to-display-visible-content-on-your-site

If the script file is available through some CDN you can add it to your site via the Business Manager (Dashboard) > Settings > Tracking & Analytics
From there you can add any script tag to your site. Just add

and you can set on which pages it will be available, and whether it's in the head or the body. This feature is only available to sites with connected domain.

I tried it, but it seems like the HTML component can’t access this script. Am I right or am I doing something wrong?

I missed the fact that you use html component.
You are right, html component is just an iframe, and therefore does not have access to the parent window.
You can use web-component (available from the add panel, right next to the html component). This is basically html+css+js with a well defined interface, that becomes part of the parent window and therefore has access to the window object

Thanks Dan, but not sure what web-component you’re referring to.
I see either HTML component or embeding a website (see attached).
Can you please clarify?

As Yisrael has already mentioned, that this is a question that you should be directing to Lottie themselves as Wix does not provide support for code from third party providers.

See here for how to add it to Wix from Lottie themselves.
https://lottiefiles.com/web-player

Read here for Wix info on using html iframes.
https://support.wix.com/en/article/using-iframes-to-display-visible-content-on-your-site

Wix cannot provide support for external codes that were not created or tested with Wix.
If you are experiencing an issue with your code snippet, please contact the provider directly.

Guy, Wix will soon release a new CustomElement that will allow you to do what you want. Meanwhile you can study the API to prepare yourself for when it’s available.

Not sure that Guy’s own Forum Profile is the link :wink:

@givemeawhisky :exploding_head: fixed

Thank you! Looking forward to them launching it

Use the script for the first component and for every other component on the same page, you dont need to load the script.

Is the CustomElement released yet? I have read through the documentation, and meet the prerequisites as a user.

???