Skip to content

fix(perf): use if in toggle_class instead of dynamic property access shenanigans #8631

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

Closed
wants to merge 1 commit into from

Conversation

akx
Copy link
Contributor

@akx akx commented May 25, 2023

Closes #8629 (is a rework of it).

Following the discussion in #8629 (and an early predecessor #3189), instead of using .toggle(... force), a plain old if proves to be about 10% faster in Chrome, likely due to JITs being able to do a better thing.

Micro-benchmark: https://gist.github.com/akx/76818fb782a232b5e08eae785cb3ee97

…s shenanigans

This is about 10% faster in Chrome, likely due to JITs being able to do a better thing

Closes sveltejs#8629 (is a rework of)
@vercel
Copy link

vercel bot commented May 25, 2023

@akx is attempting to deploy a commit to the Svelte Team on Vercel.

A member of the Team first needs to authorize it.

@dummdidumm
Copy link
Member

Closing in favor of the other PR

@dummdidumm dummdidumm closed this May 26, 2023
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