Created
March 17, 2014 14:09
-
-
Save JosePedroDias/9599806 to your computer and use it in GitHub Desktop.
minifies css rules (string). naive approach (doesn't interpret anything)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var minifyCss = function(s) { | |
s = s.replace('\n', ''); // remove newlines | |
s = s.replace(/\s+/g, ' '); // several whitespace to 1 spacebar | |
s = s.replace(/\s*([:;,{}])\s*/g, '$1'); // strips whitespace around :;,{} characters | |
s = s.replace(/\/\*(.|[\r\n])*?\*\//g, ''); // uses non-greedy matching *? to remove comments | |
return s; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment