Detect Unmatched CSS Selectors with Helium

By  on  

One thing I can't stand is extra code.  Whether it's an extra CSS or JavaScript file that's been included by the page, bloated HTML, or unoptimized images, we're making our millions of of desktop and mobile visitors pay for our laziness and mistakes.  A great tool called Helium is available to help developers detect selectors in their stylesheets that are unmatched or malformed.  Let me show you how it works!

Start by including the script in your page and initializing Helium upon load:

<script type="text/javascript" src="js/lib/helium-css/helium.js" onload="helium.init()" async></script>

As soon as the page is loaded, the developer is presented with a textarea with which they may type page URLs to test.  These pages are then loaded and a report is generated, detailing the unused selectors, malformed selectors, and pseudo-selectors which should be tested manually:

Helium CSS Textarea

Helium CSS Result

Helium is an excellent tool for identifying legacy and unnecessary CSS.  The information provided by Helium allows developers to remove unused CSS or better segment site CSS.  This tool is the perfect utility for developers looking to quickly optimize their CSS code.  In fact, I've not seen a tool so easy to implement and use.  Let me know if you agree!

Recent Features

  • By
    LightFace:  Facebook Lightbox for MooTools

    One of the web components I've always loved has been Facebook's modal dialog.  This "lightbox" isn't like others:  no dark overlay, no obnoxious animating to size, and it doesn't try to do "too much."  With Facebook's dialog in mind, I've created LightFace:  a Facebook lightbox...

  • By
    I&#8217;m an Impostor

    This is the hardest thing I've ever had to write, much less admit to myself.  I've written resignation letters from jobs I've loved, I've ended relationships, I've failed at a host of tasks, and let myself down in my life.  All of those feelings were very...

Incredible Demos

  • By
    MooTools ContextMenu Plugin

    ContextMenu is a highly customizable, compact context menu script written with CSS, XHTML, and the MooTools JavaScript framework. ContextMenu allows you to offer stylish, functional context menus on your website. The XHTML Menu Use a list of menu items with one link per item. The...

  • By
    Resize an Image Using Canvas, Drag and Drop and the File API

    Recently I was asked to create a user interface that allows someone to upload an image to a server (among other things) so that it could be used in the various web sites my company provides to its clients. Normally this would be an easy task—create a...

Discussion

  1. Did you know about mincss, written by our own Peterbe? It seem to serve the same purpose, see http://www.peterbe.com/plog/mincss

  2. Does it do the same job as CSS Usage ? (Firebug extension)

    • PH, this tool appears to support checking selectors across multiple pages. CSS Usage is current page only.

  3. PH, this tool appears to support checking selectors across multiple pages. CSS Usage is current page only.

  4. Very interesting tools , i will try it now.

    Thank you

  5. It’s a handy tool apparently but not a lot of people are using it? It is not efficient enough, or.. I haven’t tried it yet.

Wrap your code in <pre class="{language}"></pre> tags, link to a GitHub gist, JSFiddle fiddle, or CodePen pen to embed!