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

fix: Wrap SVG Mandala to reduce CPU usage #8622

Merged
merged 1 commit into from
May 9, 2023
Merged

fix: Wrap SVG Mandala to reduce CPU usage #8622

merged 1 commit into from
May 9, 2023

Conversation

Synvox
Copy link
Contributor

@Synvox Synvox commented Apr 11, 2023

Closes #8621

Summary

This wraps the SVG Mandala element in a <div> and applies the animation there instead of directly on the SVG.

Problem

Some changes to CSS properties cause the browser to re-raster the whole SVG. If you go to the MDN as it is today you can see the effect this has on CPU usage. See screenshots below.

Solution

Browsers can transform SVG without having to re-raster when the transform happens outside the SVG.

Screenshots

There are no visual changes to the Mandala on the homepage or the Contributor Spotlight section.

Before

image

After

image

Copy link
Contributor

@fiji-flo fiji-flo left a comment

Choose a reason for hiding this comment

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

Hi there, apologies for the delay. This is great!

@fiji-flo fiji-flo merged commit 35c9ae9 into mdn:main May 9, 2023
@Synvox
Copy link
Contributor Author

Synvox commented May 9, 2023

@fiji-flo Thanks!

@Synvox Synvox deleted the synvox/optimize-svg-mandala branch May 9, 2023 14:10
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.

Mandala on the homepage uses ~50% CPU
2 participants