Using a CDN for Tailwind CSS directly in your HTML file isn't the best practice for production. Here's a breakdown of the problems and a recommended solution using a build process:
Problems with Direct CDN Inclusion:
- Performance: Fetching Tailwind CSS from a CDN adds an extra HTTP request to your page load, slowing down initial rendering.
- Bundle Size: The entire Tailwind CSS library is included in your HTML, adding unnecessary weight to your page.
- Customization: It's not ideal for customizing Tailwind's defaults, as you'll need to modify the CDN's version directly.
- Cache Busting: You might not have control over the caching of the CDN, leading to issues with updates.
Best Practices: Build Process (with Vite or Parcel)