0.0
Repository is archived
No commit activity in last 3 years
No release in over 3 years
a (very) small library that counts selectors in a CSS file
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 10.0
~> 2.0

Runtime

~> 0.2
 Project Readme

A (very) small library that counts selectors in a CSS file.

This is mainly useful to detect when your CSS files have crossed the 4095 selector limit imposed by Internet Explorer 9 and lower.

Installation¶ ↑

gem install css_counter

Usage¶ ↑

require 'css_counter'

css = <<-EOS
  h1 { color: red }
  h2 { color: green }
EOS

CssCounter.new(css).selectors
=> 2

Rails¶ ↑

To ensure none of the compiled CSS files in your rails app exceed the IE selector limit, there’s a rake task you can run as part of a build process.

Add css_counter to your application Gemfile, and then run:

bundle exec rake css_counter:check_selectors