Performance issue with --tw-empty #851
Unanswered
brunoabreu
asked this question in
General
Replies: 1 comment 1 reply
-
Hey there I remember coming up with the If twin has a new option added to remove the space then the values still aren't read correctly and we end up with styles like this (from the vite-emotion-typescript example: Do you know of a way to get Emotion to read those empty values? I haven't been able to find a suitable replacement. |
Beta Was this translation helpful? Give feedback.
1 reply
# for free
to join this conversation on GitHub.
Already have an account?
# to comment
-
We are investigating a performance issue in Firefox with our app, which uses Next.js 13 (app router) +
emotion
withtwin.macro
.We noticed that the default value for empty variables inserted by
twin.macro
(var(--tw-empty,/*!*/ /*!*/)
) is causing a significant impact when the browser needs to repaint the layout. Using the default value from Tailwind, a blank space, the difference is dramatic:var(--tw-empty,/*!*/ /*!*/)
Firefox seems to benefit the most, but a performance gain is also noticeable in Google Chrome.
var(--tw-empty,/*!*/ /*!*/)
For now, we have created a stylis plugin to replace
var(--tw-empty,/*!*/ /*!*/)
with a blank space, undoing what is done bytwin.macro
. Like this:We also tried applying a patch using
yarn
to prevent this substitution thattwin.macro
makes for--tw-empty
, but it is not so simple. Unfortunately,emotion
(throughstylis
), removes the variables believing they are dead code.The best solution probably involves modifying both
twin.macro
andstylis
. But it would be helpful iftwin.macro
provided a configuration option to leave the blank space instead of making the substitution.Beta Was this translation helpful? Give feedback.
All reactions