Repository navigation
Theme UI Performance - #370
Merged
Merged
Conversation
tlgimenes
force-pushed
the
feature/theme-ui-performance
branch
from
November 10, 2020 20:27
e621149 to
3519c2a
Compare
klzns
reviewed
Nov 10, 2020
tlgimenes
force-pushed
the
feature/theme-ui-performance
branch
2 times, most recently
from
November 10, 2020 20:48
3412ff6 to
59f3862
Compare
lucis
approved these changes
Nov 10, 2020
victorhmp
approved these changes
Nov 11, 2020
tlgimenes
force-pushed
the
feature/theme-ui-performance
branch
from
November 12, 2020 13:17
178dc21 to
78d6f09
Compare
3 of 4 tasks
renatamottam
pushed a commit
that referenced
this pull request
Feb 10, 2023
* chore: Updates deps and attempts to replace * chore: Removes unused payment methods css * chore: Updates deps * chore: Updates data-attr name * chore: Updates deps * chore: updates packs * chore: Fixes style * chore: Updates fs/c package version * Triggers CI with an empty commit * Triggers CI with an empty commit
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What's the purpose of this pull request?
This PR brings many performance optimizations for our theme-ui plugin.
How it works?
This first optimization explored one of Emotion's most wanted "features". Emotion v10 works out of the box on many frameworks, a.k.a Next.JS, Gatsby and CRA. To make this work, they render a
<style/>tag right before an html tag (<div/>) and go through a process ofhydration. In this process, they appendstylenodes to the DOM head. This process is time consuming and may take a long time. However, emotion's own docs show an advanced server side rendering process where we don't need thishydrationphase to occur.Below, you can see the before/after flamechart showing the time it takes to run this function


The second optimization was due to
@emotion/is-prop-valid. This package has a HUGE (4Kb) RegExp. This RegExp can be greatly reduced with a O(1) Hash table. To be able to overwrite this package, I've used the a Webpack alias.The before/after flamechart can not be shown since this function execution disappeared after the optimization on the flamechart
The third optimization was due to how the merged theme-ui theme object was stringified into the final
.jsfile. To better understand this optimization take a look at this videoAfter these 3 optimizations combined, we went from ~60ms to ~14ms and the difference can be seen in the comparison below for the


E4e1functionHow to test it?
storecomponents
marinbrasil
References
Spread the knowledge: is there any content you used to create this PR that is worth sharing?
Extra tip: adding references to related issues or mentioning people important to this PR may be good for the documentation and reviewing process