Script identifying CSS shorthand possibilities

For my own convenience I created this script to identify css files where colors like #aaaaaa can be rewritten in the short form #aaa

(saves bandwith, but can also make it easier to identify similar colors)

grep -nE '#([0-9a-f])\1([0-9a-f])\2([0-9a-f])\3' **/*.css

output from a random project:

css/actions.css:19: color: #000000; css/actions.css:38: color: #000000 !important; css/actions.css:53: color: #ffffff !important; css/admin.css:90: color: #cccccc; css/admin.css:94: color: #aaaaaa !important;

2 Responses to “Script identifying CSS shorthand possibilities”

  1. vim Says:

    great tip, this sure does save a lot loading time, another great tip is grouping the h1 tags eg. h1,h2,h3 { font-size:1.4em; }

  2. custom t-shirts Says:

    Does truncating from 6 to 3 characters really save that much bandwidth?