Git Product home page Git Product logo

node-jsmin's Introduction

This is a node.js module for minimizing javascript (jsmin for short).

It was originally written by Doug Crockford (www.crockford.com), was ported
to javascript by Franck Marcia (www.fmarcia.info), which in turn was ported
to node.js by Peteris Krumins (www.catonmat.net).

------------------------------------------------------------------------------

The module exports 'jsmin' function:

    var jsmin = require('jsmin').jsmin;

The 'jsmin' function takes three arguments:

    * input js code
    * integer aggressiveness level (defaults to 2)
    * optional comment to prepend to output (defaults to nothing)

The aggressiveness level can be 1, 2 or 3:

    * 1 - keep original newlines in output
    * 2 - original Crockford's algorithm - remove some newlines
    * 3 - remove all newlines

Start the comments that you don't want to remove (as process of minification)
with /*! ... */


Example
-------

    var jsmin = require('./jsmin').jsmin;
    var sys = require('sys');

    sys.puts(jsmin('function    hello( a , b , c ) {   sys.log(a + b + c) }'))

Output:

    'function hello(a,b,c){sys.log(a+b+c)}'


Command-line Usage
------------------

Installing globally (using npm's -g flag) will also install a command-line
tool for using jsmin:

    jsmin [OPTIONS...] [FILENAME]

The input filename should be the last argument. If you don't specify it,
input will be read from STDIN instead.

Supported options:

    -o FILENAME
    --output FILENAME

        Specifies an output file for minified output. If not given, output
        will be written to STDOUT.

    -l LEVEL
    --level LEVEL

        Sets the aggressiveness level to be used.

    -c COMMENT
    --comment COMMENT

        Sets a comment to be prepended to the output.

    --overwrite

        If provided and an input filename was provided (rather than using
        STDIN), output will be written to the same file input was read from.

------------------------------------------------------------------------------

Have fun jsminning!


Sincerely,
Peteris Krumins
http://www.catonmat.net

node-jsmin's People

Contributors

pkrumins avatar insin avatar

Watchers

 avatar

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.