def minify_css(css):
 remove_next_comment = 1
 for css_comment in css_comments.findall(css):
  if (css_comment[(-3):] == '\\*/'):
   remove_next_comment = 0
   continue
  if remove_next_comment:
   css = css.replace(css_comment, '')
  else:
   remove_next_comment = 1
 css = re.sub('\\s\\s+', ' ', css)
 css = re.sub('\\s+\\n', '', css)
 for char in ('{', '}', ':', ';', ','):
  css = re.sub((char + '\\s'), char, css)
  css = re.sub(('\\s' + char), char, css)
 css = re.sub('}\\s(#|\\w)', '}\\1', css)
 css = re.sub(';}', '}', css)
 css = re.sub('}//-->', '}\\n//-->', css)
 return css.strip()

def minify_css ( css ) : remove_next_comment = 1 for css_comment in css_comments . findall ( css ) : if ( css_comment [ ( - 3 ) : ] == '\\*/' ) : remove_next_comment = 0 continue if remove_next_comment : css = css . replace ( css_comment , '' ) else : remove_next_comment = 1 css = re . sub ( '\\s\\s+' , ' ' , css ) css = re . sub ( '\\s+\\n' , '' , css ) for char in ( '{' , '}' , ':' , ';' , ',' ) : css = re . sub ( ( char + '\\s' ) , char , css ) css = re . sub ( ( '\\s' + char ) , char , css ) css = re . sub ( '}\\s(#|\\w)' , '}\\1' , css ) css = re . sub ( ';}' , '}' , css ) css = re . sub ( '}//-->' , '}\\n//-->' , css ) return css . strip ( )
little css minifier .