code: def minify_css(css):
      
      # Inspired by slimmer by Peter Bengtsson
      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
  
      # >= 2 whitespace becomes one whitespace
      css = re.sub(r'\s\s+', ' ', css)
      # no whitespace before end of line
      css = re.sub(r'\s+\n', '', css)
      # Remove space before and after certain chars
      for char in ('{', '}', ':', ';', ','):
          css = re.sub(char + r'\s', char, css)
          css = re.sub(r'\s' + char, char, css)
      css = re.sub(r'}\s(#|\w)', r'}\1', css)
      # no need for the ; before end of attributes
      css = re.sub(r';}', r'}', css)
      css = re.sub(r'}//-->', r'}\n//-->', css)
      return css.strip()
docs: Little css minifier