DEV Community

Cover image for I Reduced Our CSS Size by 20% Using This Tailwind Hack - You Won't Believe What Happened Next at @Parentune!
Abhi Raj
Abhi Raj

Posted on

I Reduced Our CSS Size by 20% Using This Tailwind Hack - You Won't Believe What Happened Next at @Parentune!

At our @Parentune Gurugram headquarter, we heavily focus on SEO and increasing our user base through organic channels, we realized our site’s CSS was bloated with unused styles, negatively impacting our SEO. We turned to PageSpeed Insights to understand our site’s performance issues and confirmed the problem using the DevTools Coverage tab.

Image description

Here’s how we tackled it:

  1. Consulted Tailwind Docs: We started by thoroughly reading the Tailwind CSS optimization guide. This provided us with the necessary steps to streamline our CSS for production.

  2. Modified Package.json: We updated our package.json file to automate the CSS build process. Here’s the relevant snippet:

   "build:css": "npx tailwindcss -o src/build.css --minify",
   "build": "npm run build:css && react-scripts build",
Enter fullscreen mode Exit fullscreen mode
  1. Updated index.tsx: To ensure we used the optimized CSS, we modified our index.tsx:
   // import './index.css';
   import './build.css';
Enter fullscreen mode Exit fullscreen mode
  1. Moved Fonts to CDN: We shifted our heavy fonts to a CDN and served them asynchronously to further enhance performance.

The Results:

Since implementing these changes, we’ve noticed significant improvements in our SEO scores and overall site performance. We are confident these enhancements will continue to drive better SEO results.

Optimizing your CSS can seem daunting, but with the right tools and steps, it can lead to substantial performance gains. Give it a try and watch your site speed and SEO improve!

Feel free to reach out for any kind of help, open for change😊

Top comments (1)

Collapse
 
shaogat_alam_1e055e90254d profile image
Shaogat Alam

Interesting topic! Everything is explained articulately and clearly. For your project, consider checking out this free npm package: select-paginated.