Giter Site home page Giter Site logo

cssgzmin's Introduction

CSS GZip Minifier Build Status

A port of barryvan's CssMin Java project to JavaScript/NPM.

From the CSSMin github README:

What is it?

CSSMin takes your CSS file and strips out everything that's not needed -- spaces, extra semicolons, redundant units, and so on. That's great, but there are loads of programs that do that. A shell script could do that! So what makes CSSMin different?

When you deliver content over the web, best practice is to deliver it gzipped. CSSMin takes your CSS file, and optimises it for gzip compression. This means that there's a smaller payload delivered over the wire, which results in a faster experience for your users. It does this optimisation by ensuring that the properties inside your selectors are ordered consistently (alphabetically) and in lower case. That way, the gzip algorithm can work at its best.

What this means in practice is that your gzipped CSSMin-ed files are significantly smaller than plain gzipped CSS, and noticeably smaller than files that have been compressed by other means (say, YUI).

What does it do?

  • Replaces font-weight values like 'bold' with their numeric counterparts;
  • Strips quotes wherever possible;
  • Changes as much of the contents to lowercase as possible;
  • Strips all comments from the source;
  • Removes unnecessary whitespace; and, most importantly,
  • Reorders the properties within your selectors alphabetically.

Usage as a command line tool

Install:

npm install -g cssgzmin

Usage:

cssgzmin infile [outfile]

Will write to stdout if outfile omitted

Usage as a module

Install

npm install --save cssgzmin

Usage:

const minify = require('cssgzmin').minify;

console.log(minify('.somerule { border: 0px; } .morerules { background: darkblue; }'));

Requirements

This tool was written for NodeJS 6+, to take advantage of ES6 features. Running the source through Babel would probably allow it run with older versions of Node. If there's high enough demand I'll consider making that a permanent build step.

Contributors

cssgzmin is as port of CSSMin to JavaScript/NPM, which was originally written, and is maintained by, Barry van Oudtshoorn. See CssMin for a full list of contributors to the original project.

This JavaScript port was originally written by, and is maintained by, Simon Bracegirdle.

License

cssgzmin is licensed under the BSD License. See LICENSE for details.

cssgzmin's People

Contributors

sbracegirdle avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

cssgzmin's Issues

Publish to npm

And also...

  • Test CLI after npm install -g on fresh system
  • Test module import in fresh project

Error when attempting to strip comments

Comments not being stripped in sheetProcessor, causing errors downstream in ruleProcessor

1) sheetProcessor tests should minify test.advanced.css:
     Uncaught Error: Found 1 parts, expected exactly 2 for line ( /* Ooooh, a media query */
        )

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.