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

Performance improvement to the hide method #434

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

vovayatsyuk
Copy link
Contributor

This PR removes unnecessary style recalculation when using the hide method. I faced a performance issue when started calling hide on thousands of elements.

The improvement is made by getting rid of computeStyle usage when calling hide and using ele.style.display only. Because it doesn't matter what display value was before hiding, if display is not inside the inline style attribute.

Here is the jQuery implementation I used as a reference: https://github.com/jquery/jquery/blob/main/src/css/showHide.js#L44-L65

Here are the screenshots before PR (Total scripting 4x slowdown: 5 seconds):

Zoomed out Zoomed in
Screenshot from 2024-12-20 09-38-42 Screenshot from 2024-12-20 09-39-03

Here are the screenshots after PR (Total scripting 4x slowdown: 1 second):

Zoomed out Zoomed in
Screenshot from 2024-12-20 09-41-40 Screenshot from 2024-12-20 09-42-03

vovayatsyuk added a commit to breezefront/module-breeze that referenced this pull request Dec 20, 2024
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.

1 participant