You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, so we have been using tailwind-merge across all of our components of our site, we did not notice it at first but over time this utility became a huge performance bottleneck adding multiple seconds to our erb rendering time.
By adding Rails.cache on the classnames we saw performance improvements of 4 to 8 times in page load speed for our pages.
classnames = "my tailwind classes"
Rails.cache.fetch(classnames) do
TailwindMerge::Merger.new(
config: {
conflicting_class_groups: {
**TailwindMerge::Config::DEFAULTS[:conflicting_class_groups],
text: %w[xs xsm sm md lg xl 2xl 3xl 4xl]
},
class_groups: {
**TailwindMerge::Config::DEFAULTS[:class_groups],
"font-size" => [{ "text" => ["base", TailwindMerge::Config::IS_TSHIRT_SIZE, TailwindMerge::Config::IS_ARBITRARY_LENGTH, "xsm"] }]
}
}
).merge(classnames)
end
While Rails.cache may not be the best solution for non Rails projects caching in general has a huge impact on performance.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
Hi, so we have been using tailwind-merge across all of our components of our site, we did not notice it at first but over time this utility became a huge performance bottleneck adding multiple seconds to our erb rendering time.
By adding Rails.cache on the classnames we saw performance improvements of 4 to 8 times in page load speed for our pages.
While Rails.cache may not be the best solution for non Rails projects caching in general has a huge impact on performance.
Hope this helps someone :-)
Beta Was this translation helpful? Give feedback.
All reactions