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

Don't initialize twMerge() if it isn‘t used #4

Closed
dcastil opened this issue Jul 21, 2021 · 0 comments · Fixed by #7
Closed

Don't initialize twMerge() if it isn‘t used #4

dcastil opened this issue Jul 21, 2021 · 0 comments · Fixed by #7
Labels
context-v0 Related to tailwind-merge v0 feature Is new feature

Comments

@dcastil
Copy link
Owner

dcastil commented Jul 21, 2021

Initializing twMerge() is the most expensive operation, so we want to be smart about it. There are currently two scenarios in which this computation isn't necessary:

  1. When someone uses createTailwindMerge() to create a custom merge function, it doesn't make sense to initialize twMerge() because it probably won't be even imported from the package. Maybe tree shaking removes the logic already, but I should check whether that's the case.

  2. If an app doesn't call twMerge() during the initial render, we're slowing down app startup time for no reason. In that case it would be nice to delay initialization until the function is needed.

@dcastil dcastil changed the title Make sure twMerge() doesn‘t get initialized if it isn‘t used Don't initialize twMerge() if it isn‘t used Aug 1, 2021
@dcastil dcastil added the context-v0 Related to tailwind-merge v0 label Oct 30, 2023
@dcastil dcastil added feature Is new feature and removed feature request labels Oct 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
context-v0 Related to tailwind-merge v0 feature Is new feature
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant