Getting Started

Optimizing for Production

Getting the most performance out of Tailwind CSS projects.

Tailwind CSS is incredibly performance focused and aims to produce the smallest CSS file possible by only generating the CSS you are actually using in your project.

Combined with minification and network compression, this usually leads to CSS files that are less than 10kB, even for large projects. For example, Netflix uses Tailwind for Netflix Top 10 and the entire website delivers only 6.5kB of CSS over the network.

With CSS files this small, you don’t have to worry about complex solutions like code-splitting your CSS for each page, and can instead just ship a single small CSS file that’s downloaded once and cached until you redeploy your site.

For the smallest possible production build, we recommend minifying your CSS with a tool like cssnano, and compressing your CSS with Brotli.

If you’re using Tailwind CLI, you can minify your CSS by adding the --minify flag:

  1. npx tailwindcss -o build.css --minify

If you’ve installed Tailwind as a PostCSS plugin, add cssnano to the end of your plugin list:

postcss.config.js

  1. module.exports = {
  2. plugins: {
  3. tailwindcss: {},
  4. autoprefixer: {},
  5. ...(NODE_ENV === 'production' ? { cssnano: {} } : {})
  6. }
  7. }

If you’re using a framework, check the documentation as this is often handled for you in production automatically and you don’t even need to configure it.