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.
curl --form "source=@./styles/global.less" https://minify.pelicandd.com/api/v1/less > styles/g.min.css
curl --form "source=@./js/global.js" https://minify.pelicandd.com/api/v1/js > js/g.min.js
curl --form "source=@./js/global.js" https://minify.pelicandd.com/api/v1/js?level=WHITESPACE_ONLY > js/g.min.js
curl --form "source=@./js/global.js" --form "externs=@./js/jquery-2.1.js" https://minify.pelicandd.com/api/v1/js > js/g.min.js
curl --form "source=@./js/global.js" --form "special-externs=jquery-1.9" https://minify.pelicandd.com/api/v1/js > js/g.min.js
curl --form "source=@./js/global.js" https://minify.pelicandd.com/api/v1/es6 > js/g.min.js
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
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, 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:
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
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 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 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)
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