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

[4.1.1] Tailwindcss v4.1.x too slower,twenty times slower than 4.0.x #17522

Closed
zyycn opened this issue Apr 3, 2025 · 10 comments · Fixed by #17511
Closed

[4.1.1] Tailwindcss v4.1.x too slower,twenty times slower than 4.0.x #17522

zyycn opened this issue Apr 3, 2025 · 10 comments · Fixed by #17511

Comments

@zyycn
Copy link

zyycn commented Apr 3, 2025

What version of Tailwind CSS are you using?

v4.1.x

What build tool (or framework if it abstracts the build tool) are you using?

Vite 6.2.4

What version of Node.js are you using?

v22.14.0

What browser are you using?

Chrome,

What operating system are you using?

Windows

Reproduction URL

https://github.com/zyycn/tailwindcss-v4.1.x-speed

Describe your issue

Tailwindcss v4.1.x ,hot update in 4.0.x is between 100ms-200ms,but in 4.1.x is 2.3s-3s !

Image
Image

@zyycn zyycn changed the title [4.1.1] Tailwindcss v4.1.x too slower,three times slower than 4.0.x [4.1.1] Tailwindcss v4.1.x too slower,twenty times slower than 4.0.x Apr 3, 2025
@MGRatEJOT
Copy link

MGRatEJOT commented Apr 3, 2025

Same here. When using Tailwindcss 4.1.X with Vite the HMR time is increased from ~100ms to ~1.5s on my machine.

@wongjn
Copy link
Contributor

wongjn commented Apr 3, 2025

Might be fixed by #17511

@zyycn
Copy link
Author

zyycn commented Apr 3, 2025

Might be fixed by #17511

maybe ,i just use this code fix it right now

@import 'tailwindcss' source(none);
@source '../';

@MGRatEJOT hi, use it improve tailwindcss speed

@leeuwd
Copy link

leeuwd commented Apr 3, 2025

Thanks!

Discovered this issue since I was initially looking at Next.js and/or Turbopack compilation issues (see vercel/next.js#77624).

Turns out it was indeed Tailwind CSS v4 (for me).

The context is a Turborepo monorepo with Next.js 15.2.4.

Fix

Before

@import 'tailwindcss';

@source './../components/**/*.{ts,tsx}';
@source './../../../**/apps/{data,web}/**/*.{ts,tsx}';

After

@import 'tailwindcss' source(none);

@source '../components';
@source '../../../../apps/data';
@source '../../../../apps/web';

@philipp-spiess
Copy link
Member

Hey folks! Do you mind running the dev server with the DEBUG=1 env variable set and posting the timing information it prints there? Trying to confirm that it's the same part that we want to address via #17511

@leeuwd
Copy link

leeuwd commented Apr 3, 2025

Hey folks! Do you mind running the dev server with the DEBUG=1 env variable set and posting the timing information it prints there? Trying to confirm that it's the same part that we want to address via #17511

Sure thing.

Before (very slow compilation)

web:dev: [0.17ms] [@tailwindcss/postcss] ../../packages/ui/src/lib/miistafontsans_b506600b.module.css
web:dev: [0.15ms]   ↳ Quick bail check
web:dev: 
web:dev: 
web:dev: [492.34ms] [@tailwindcss/postcss] ../../packages/ui/src/styles/globals.css
web:dev: [  0.02ms]   ↳ Quick bail check
web:dev: [116.58ms]   ↳ Setup compiler
web:dev: [  0.26ms]     ↳ PostCSS AST -> Tailwind CSS AST
web:dev: [116.29ms]     ↳ Create compiler
web:dev: [  0.60ms]   ↳ Register full rebuild paths
web:dev: [  3.86ms]   ↳ Setup scanner
web:dev: [ 20.83ms]   ↳ Scan for candidates
web:dev: [315.98ms]   ↳ Register dependency messages
web:dev: [ 26.14ms]   ↳ Build utilities
web:dev: [  2.93ms]   ↳ Transform Tailwind CSS AST into PostCSS AST
web:dev: [  4.91ms]   ↳ Update PostCSS AST
web:dev: 
web:dev: 
web:dev: [0.23ms] [@tailwindcss/postcss] ../../packages/ui/src/lib/[redacted].module.css
web:dev: [0.22ms]   ↳ Quick bail check
web:dev: 
web:dev:  ✓ Compiled /[locale] in 6.8s

After (so when it works fine, with the fix as described at #17522 (comment)

web:dev: [331.25ms] [@tailwindcss/postcss] ../../packages/ui/src/styles/globals.css
web:dev: [  0.04ms]   ↳ Quick bail check
web:dev: [118.56ms]   ↳ Setup compiler
web:dev: [  0.36ms]     ↳ PostCSS AST -> Tailwind CSS AST
web:dev: [118.17ms]     ↳ Create compiler
web:dev: [  0.13ms]   ↳ Register full rebuild paths
web:dev: [  6.13ms]   ↳ Setup scanner
web:dev: [ 29.00ms]   ↳ Scan for candidates
web:dev: [142.73ms]   ↳ Register dependency messages
web:dev: [ 25.56ms]   ↳ Build utilities
web:dev: [  3.30ms]   ↳ Transform Tailwind CSS AST into PostCSS AST
web:dev: [  5.45ms]   ↳ Update PostCSS AST
web:dev: 
web:dev: 
web:dev: [0.16ms] [@tailwindcss/postcss] ../../packages/ui/src/lib/[redacted]_b506600b.module.css
web:dev: [0.15ms]   ↳ Quick bail check
web:dev: 
web:dev: 
web:dev: [0.02ms] [@tailwindcss/postcss] ../../packages/ui/src/lib/[redacted].module.css
web:dev: [0.01ms]   ↳ Quick bail check
web:dev: 
web:dev:  ✓ Compiled in 423ms

My setup:

Using Tailwind CSS 4.1.1.

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 24.4.0: Wed Mar 19 21:16:34 PDT 2025; root:xnu-11417.101.15~1/RELEASE_ARM64_T6000
  Available memory (MB): 16384
  Available CPU cores: 10
Binaries:
  Node: 22.14.0
  npm: 11.2.0
  Yarn: N/A
  pnpm: 10.7.1
Relevant Packages:
  next: 15.2.4 // Latest available version is detected (15.2.4).
  eslint-config-next: N/A
  react: 19.1.0
  react-dom: 19.1.0
  typescript: 5.8.2
Next.js Config:
  output: N/A

@zyycn
Copy link
Author

zyycn commented Apr 3, 2025

Hey folks! Do you mind running the dev server with the DEBUG=1 env variable set and posting the timing information it prints there? Trying to confirm that it's the same part that we want to address via #17511

https://github.com/zyycn/tailwindcss-v4.1.x-speed hi , use this repository,here is debug info.

Image
Image

@philipp-spiess
Copy link
Member

@leeuwd Thanks! This is indeed consistent with what we'd expect to be resolved by #17511. We'll post an update there as soon as this fix is out, probably later today!

@HasanMothaffar
Copy link

@leeuwd I can confirm your fix works for me. Compilation times went from 10-20 seconds to ~300ms. I'm using Next.js 15.2.4 with Turbopack.

@RobinMalfait
Copy link
Member

Hey!

This should be fixed by #17511 and will be available in the next release (later today).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants