Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perf: reduce the unnecessary use of ref #526

Merged
merged 2 commits into from
Mar 17, 2024

Conversation

Mini-ghost
Copy link
Contributor

Inside <Vue3Lottie>, animationData is used to store the JSON data passed by the user:

const animationData = ref<any>()

I checked the context, and ref seems this isn't a necessary presence. I tried making it a regular variable instead of a Vue ref, and there was a significant performance improvement.

After this PR, using dog.json as an example, it can reduce the time by about 25% (measuring the execution of loadLottie()).

@Mini-ghost Mini-ghost requested a review from megasanjay as a code owner March 2, 2024 06:27
Copy link

vercel bot commented Mar 2, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
vue3-lottie ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 17, 2024 0:43am

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have skipped reviewing this pull request. All of the files appear to be ones we're not sure how to review. We're working on it!

@megasanjay
Copy link
Owner

Thank you for the PR. I just need to doublecheck #502 with this change since I think they might be related.

@Mini-ghost
Copy link
Contributor Author

@megasanjay Thank you for your review. 💚

I have looked into issue #502 and believe it is unrelated to this issue. I have reproduced the problem in the playground and found a solution. I will open another PR to resolve this issue as soon as possible.

@megasanjay megasanjay changed the base branch from main to v3.3 March 17, 2024 00:39
@megasanjay megasanjay merged commit f1502e9 into megasanjay:v3.3 Mar 17, 2024
4 of 5 checks passed
megasanjay added a commit that referenced this pull request Mar 17, 2024
* fix: ensure `loadLottie` is called after the component mounted (#527)

* fix: ensure `loadLottie` invoke after `lottieAnimationContainer` is mounted

* refactor: remove unnecessary `nextTick`

* perf: educe the unnecessary use of `ref` (#526)

Co-authored-by: Sanjay Soundarajan <sanjay.16@live.com>

* refactor: switch to smaller dependencies to reduce bundle size (#525)

* 🐛  fix: performance improvements and suspense bug fixes

* 🔖 chore: prep for releasing v3.3

* 🔖 chore: prep for releasing v3.3 beta

---------

Co-authored-by: Alex Liu <dsa1314@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants