Skip to main content
Test Double company logo
Services
Services Overview
Holistic software investment consulting
Software Delivery
Accelerate quality software development
Product Impact
Drive results that matter
Legacy Modernization
Renovate legacy software systems
Pragmatic AI
Solve business problems without hype
Upgrade Rails
Update Rails versions seamlessly
DevOps
Scale infrastructure smoothly
Technical Recruitment
Build tech & product teams
Technical & Product Assessments
Uncover root causes & improvements
Case Studies
Solutions
Accelerate Quality Software
Software Delivery, DevOps, & Product Delivery
Maximize Software Investments
Product Performance, Product Scaling, & Technical Assessments
Future-Proof Innovative Software
Legacy Modernization, Product Transformation, Upgrade Rails, Technical Recruitment
About
About
What's a test double?
Approach
Meeting you where you are
Founder's Story
The origin of our mission
Culture
Culture & Careers
Double Agents decoded
Great Causes
Great code for great causes
EDI
Equity, diversity & inclusion
Insights
All Insights
Hot takes and tips for all things software
Leadership
Bold opinions and insights for tech leaders
Developer
Essential coding tutorials and tools
Product Manager
Practical advice for real-world challenges
Say Hello
Test Double logo
Menu
Services
BackGrid of dots icon
Services Overview
Holistic software investment consulting
Software Delivery
Accelerate quality software development
Product Impact
Drive results that matter
Legacy Modernization
Renovate legacy software systems
Pragmatic AI
Solve business problems without hype
Cycle icon
DevOps
Scale infrastructure smoothly
Upgrade Rails
Update Rails versions seamlessly
Technical Recruitment
Build tech & product teams
Technical & Product Assessments
Uncover root causes & improvements
Case Studies
Solutions
Solutions
Accelerate Quality Software
Software Delivery, DevOps, & Product Delivery
Maximize Software Investments
Product Performance, Product Scaling, & Technical Assessments
Future-Proof Innovative Software
Legacy Modernization, Product Transformation, Upgrade Rails, Technical Recruitment
About
About
About
What's a test double?
Approach
Meeting you where you are
Founder's Story
The origin of our mission
Culture
Culture
Culture & Careers
Double Agents decoded
Great Causes
Great code for great causes
EDI
Equity, diversity & inclusion
Insights
Insights
All Insights
Hot takes and tips for all things software
Leadership
Bold opinions and insights for tech leaders
Developer
Essential coding tutorials and tools
Product Manager
Practical advice for real-world challenges
Say hello
Developers
Developers
Developers
Software tooling & tips

How to find and remove dead CSS

People hate maintaining CSS for lots of reasons, but figuring out if it's safe to delete old styles is a vexing problem without any great solutions. Here's one way to do it by using, of all things, code coverage!
Justin Searls
|
June 3, 2021
Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.

Do you have a pile of old CSS styles that you’re pretty sure are no longer referenced anywhere, but that you’re nevertheless afraid to delete because you have no way to be sure that no musty corners of your site somehow depend on them to render correctly?

I’ve been saying for years that the most valuable uses for code coverage have nothing to do with testing, and today I was happy to add another great use case: gaining confidence over which styles are actually safe to delete. The approach in this screencast shows a way to record and combine the code coverage results for our site’s CSS across each web page.

Other automated approaches for identifying dead styles exist, but modern CSS has introduced so many context-dependent selectors (e.g. media queries and pseudo-elements) that nothing can beat recording coverage while manually resizing and clicking around your custom components like only you know how.

Stuff covered in this video:

  • How we use our static-rails gem to host our static blog & website inside a Rails API monorepo
  • CSS Tricks' overview on this topic
  • A tutorial on Chrome’s DevTools Coverage drawer
  • The DisCoverage Chrome extension for munging multiple coverage exports

Related Insights

🔗
Building a linkblog with Hugo, Tailwind and Netlify
🔗
How to build a search engine with Ruby on Rails

Explore our insights

See all insights
Developers
Developers
Developers
Red-Green-Refactor your context

You committed the fix. But everything you learned along the way went nowhere. A practice borrowed from TDD's red-green-refactor loop gives that hard-won knowledge somewhere to land.

by
Rick Reilly
Leadership
Leadership
Leadership
This has happened before. It's happening again.

Doc Norton has navigated two genuine sea changes in software development—mainframes to PCs and desktop to web. Agentic coding is the third, but unlike the prior shifts that expanded the profession, this one compresses it. The timeline to move is shorter than you think.

by
Doc Norton
Developers
Developers
Developers
Three Amigos with AI: Stop building the wrong thing faster

AI coding assistants are remarkably fast at building the wrong thing. This post adapts the Three Amigos practice to give AI an unambiguous contract—before the first commit, not after the fifty-seventh.

by
Andy Vida
Letter art spelling out NEAT

Join the conversation

Technology is a means to an end: answers to very human questions. That’s why we created a community for developers and product managers.

Explore the community
Test Double Executive Leadership Team

Learn about our team

Like what we have to say about building great software and great teams?

Get to know us
Test Double company logo
Improving the way the world builds software.
What we do
Services OverviewSoftware DeliveryProduct StrategyLegacy ModernizationPragmatic AIDevOpsUpgrade RailsTechnical RecruitmentAssessments
Who WE ARE
About UsCulture & CareersGreat CausesEDIOur TeamContact UsNews & AwardsN.E.A.T.
Resources
Case StudiesAll InsightsLeadership InsightsDeveloper InsightsProduct InsightsPairing & Office Hours
NEWSLETTER
Sign up hear about our latest innovations.
Your email has been added!
Oops! Something went wrong while submitting the form.
Standard Ruby badge
614.349.4279hello@testdouble.com
Privacy Policy
© 2020 Test Double. All Rights Reserved.