Minification service

Welcome, None

The API is intended to be used for minification of JavaScript and conversion of LESS to CSS.

You may also be interested by the source code. If you have any questions, contact us at contact@pelicandd.com.

Cheat sheet

LESS file:
curl --form "source=@./styles/global.less" https://minify.pelicandd.com/api/v1/less > styles/g.min.css
JavaScript file:
curl --form "source=@./js/global.js" https://minify.pelicandd.com/api/v1/js > js/g.min.js
JavaScript file, whitespace only:
curl --form "source=@./js/global.js" https://minify.pelicandd.com/api/v1/js?level=WHITESPACE_ONLY > js/g.min.js
JavaScript externs:
curl --form "source=@./js/global.js" --form "externs=@./js/jquery-2.1.js" https://minify.pelicandd.com/api/v1/js > js/g.min.js
JavaScript special externs:
curl --form "source=@./js/global.js" --form "special-externs=jquery-1.9" https://minify.pelicandd.com/api/v1/js > js/g.min.js
ES6 file:
curl --form "source=@./js/global.js" https://minify.pelicandd.com/api/v1/es6 > js/g.min.js

JavaScript minification

JavaScript minification is based on Google Closure Compiler set with advanced optimization used by default. The compilation level can be changed using level URI parameter. Those are the valid values: WHITESPACE_ONLY, SIMPLE_OPTIMIZATIONS, ADVANCED_OPTIMIZATIONS.

The API accepts both direct source code through POST and files containing the source code. In both cases, the API accepts one or several source parameters.

Example of a POST request where JavaScript code is contained in the files passed to the API:

curl --form "source=@./file1.js" --form "source=@./file2.js" https://minify.pelicandd.com/api/v1/js

Example of a POST request where JavaScript code is passed directly:

curl --data "source=contents1&source=contents2" https://minify.pelicandd.com/api/v1/js

Source map

In order to generate a source map, source-map option can be used like this:

curl --form "source=@./js/global.js" --form "source-map=1" https://minify.pelicandd.com/api/v1/js > js/g.min.js

When this option is specified, the result is not a JavaScript source, but a ZIP archive using DEFLATE compression algorithm and containing two files:global.js and global.js.map.

Externs

Externs, as used in Closure Compiler, are supported through externs parameter. In the same way as the source files, externs can be sent both as files or as in-form data.

Example of a POST request where externs are contained in a file passed to the API:

curl --form "source=@./file1.js" --form "source=@./file2.js" --form "externs=@./externs.js" https://minify.pelicandd.com/api/v1/js

Example of a POST request where externs code is passed directly:

curl --data "source=contents1&source=contents2&externs=contents3" https://minify.pelicandd.com/api/v1/js

The following externs can be used without having to upload them:

  • angular-1.0
  • angular-1.2
  • angular-1.2-http-promise
  • angular-1.2-http-promise_templated
  • angular-1.2-q
  • angular-1.2-q_templated
  • angular-1.3
  • angular-1.3-http-promise
  • angular-1.3-http-promise_templated
  • angular-1.3-q
  • angular-1.3-q_templated
  • angular-material
  • angular_ui_router
  • chrome_extensions
  • es6
  • facebook_javascript_sdk
  • fileapi_synchronous
  • google_analytics_api
  • google_feed_api
  • google_loader_api
  • google_maps_api_v2
  • google_tag_manager_api
  • google_visualization_api
  • google_youtube_iframe
  • jasmine
  • jquery-1.3.2.externs
  • jquery-1.4.3
  • jquery-1.4.4
  • jquery-1.5
  • jquery-1.6
  • jquery-1.7
  • jquery-1.8
  • jquery-1.9
  • processing-1.4.8
  • silverlight
  • underscore-1.3.1
  • underscore-1.5.2
  • universal_analytics_api
  • w3c_audio
  • w3c_css
  • w3c_eventsource
  • w3c_gamepad
  • w3c_midi
  • w3c_pointer_events
  • w3c_speech
  • youtubeplayer

The files are taken from Closure Compiler externs directory. In order to use those externs, one should use special-externs parameter.

Example of a POST request where externs are contained in a file passed to the API:

curl --form "source=@./file1.js" --form "source=@./file2.js" --form "special-externs=jquery-1.9" https://minify.pelicandd.com/api/v1/js

Debugging

A debug option makes it possible to get transformed code while keeping new lines. This can be useful, for example, when debugging the JavaScript code itself. In order to enable debug option, pass debug=1 in the POST request.

Example of a POST request with debugging:

curl --form "source=@./file1.js" --form "source=@./file2.js" --form "debug=1" https://minify.pelicandd.com/api/v1/js

ES6 minification

ES6 is minified using Douglas Crockford's jsmin.

It is used exactly the same as JavaScript minification documented below, the only difference being the URI:

curl --form "source=@./file1.js" --form "source=@./file2.js" https://minify.pelicandd.com/api/v1/es6

The levels parameter is not supported yet.

The externs are not needed, since the input code is not compiled per se, but only minified.

LESS processing

LESS processing is based on the official lessc command line tool.

The API accepts both direct source code through POST and files containing the source code. In both cases, the API accepts one or several source parameters.

Example of a POST request where LESS code is contained in the files passed to the API:

curl --form "source=@./file1.less" --form "source=@./file2.less" https://minify.pelicandd.com/api/v1/less

The same request can be done in Python:

import requests

with open("file1.less") as f:
    file1 = f.read()

with open("file2.less") as f:
    file2 = f.read()

files = [
    ("source", ("file1.less", file1)),
    ("source", ("file2.less", file2)),
]

r = requests.post("https://minify.pelicandd.com/api/v1/less", files=files)

Example of a POST request where LESS code is passed directly:

curl --data "source=contents1&source=contents2" https://minify.pelicandd.com/api/v1/less

The same request can be done in Python:

import requests

data = [
    ("source", "contents1"),
    ("source", "contents2"),
]
                
r = requests.post("https://minify.pelicandd.com/api/v1/less", data=data)

Debugging

A debug option makes it possible to get transformed code while keeping new lines and white space. This can be useful, for example, when debugging the LESS code itself. In order to enable debug option, pass debug=1 in the POST request.

Example of a POST request with debugging:

curl --form "source=@./file1.less" --form "source=@./file2.less" --form "debug=1" https://minify.pelicandd.com/api/v1/less