question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

DevTools very slow when importing @tailwindcss/ui

See original GitHub issue

Describe the bug

Tailwind UI is a CSS framework which during dev phase bundles a LOT of CSS to the webpage, around 4 MB. It seems that this, combined with how Vite inserts its CSS (using a script tag for HMR purposes) makes it very slow to parse by the browser, to the point of being almost unusable. Here’s a video of how Chrome on a recent Macbook Pro handles a simple Vite + Tailwind starter project: https://drive.google.com/file/d/1rTiJ13VHgtvF4QtxS-Os9bbduyggsaQE/view?usp=sharing

Reproduction

Here’s a sample project that can be used to reproduce the issue, note that you also have to add @tailwindcss/ui as described in the readme (the issue shows itself without it, but it’s even more pronounced with it): https://github.com/posva/vite-tailwind-starter

System Info

  • vite version: 1.0.0-rc.4
  • vue version: 3.0.0-0
  • Operating System: macOS 10.15.4 Catalina
  • Node version: v12.16.3

Possible solution

Maybe it would be better if Vite supported adding certain CSS files that are not meant to be changed statically, using <link> tags instead?

Edit: Just checked and indeed, when the whole 4.6 MB CSS file generated by Tailwind gets imported in index.html using plain <link> tag from the public/ directory the problem disappears, plus the site loads faster (previously it hangs for a few seconds on first load, as can be seen on the video above). However it’s impractical to do this by hand because on every tailwindcss update one would need to manually regenerate the CSS file and replace it in the public directory, hence the need for Vite to handle that automatically if possible.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:10
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

4reactions
underfincommented, Oct 21, 2020

This is already fixed. You can use Canary for now and wait chrome next release published.

0reactions
maciej-trebaczcommented, Oct 11, 2020

These are always mac problems. There is nothing wrong with vite nor tailwind. Update catalina and node to latest lts. Try with incognito and or disabling unused extensions. Try Firefox, vivaldi etc and see if the problem persists.

This is not a Mac problem. I’ve tried different things, I’m on latest versions of software, I’ve also tried Firefox devtools and the problem exists there as well (although it’s not as bad as on Chrome). Finally I’ve checked Chrome on Windows and the issue is also present there.

My theory is that browsers don’t optimize for constructed CSS very well and until they do it would be nice to have some kind of fallback, otherwise Vite and Tailwind (or any other more sophisticated CSS framework) are now pretty much unusable together 😦.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Optimizing for Production - Tailwind CSS
Tailwind CSS is incredibly performance focused and aims to produce the smallest CSS file possible by only generating the CSS you are actually...
Read more >
Webpack dev server slow compile on css change with tailwind
Anytime I made a change it had to re-compile everything and the tailwind css alone is several mb so this I guess is...
Read more >
Speeding Up Tailwind CSS Builds - nystudio107
One issue that we've run into recently is that build times can be slow in local development, where you really want the speed...
Read more >
Why I Don't Like Tailwind CSS | Aleksandr Hovhannisyan
Note: I'm wrong here. I should have done more research into Tailwind to understand that it is in fact not as slow as...
Read more >
UI Devtools for Tailwind CSS
This friction is especially visible if you use a utility or tokens based framework like Tailwind CSS. You need to continously shift your...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found