Minifying JS from an input string or urls.
.Maui Javascript Minify API for minifying JS documents from an input string or urls.
POSTGET *https://api.dotmaui.com/client/1.0/jsmin/
Parameters
| Field | Type | Description | Required |
|---|---|---|---|
| apikey | String |
.Maui Api key |
True |
| js | String |
JavaScript valid code |
1 |
| url | String |
Valid URL to a javascipt file |
1 |
| url[] | String[] |
One or more valid URL to Javascipt files |
1 |
| mode | String |
Accepted values are:
|
False |
| compression | String |
Accepted values are:
|
False |
| asciionly | Boolean |
Escape Unicode characters in strings and regexps. Default is false. |
False |
1 There must be one of these values
Success 200 - Default Mode
It will be a string with the JavaScript code minimized
HTTP/1.1 200 OK
function myFunction(n,t){return n*t}var x=myFunction(4,3);
Success 200 - CDN Mode
| Field | Type | Description |
|---|---|---|
| url | String |
The url where the minimized file was saved |
| size | Integer |
File size in bytes |
| UID | String |
Unique alphanumeric ID in the .Maui CDN |
HTTP/1.1 200 OK
{
"url": "https://cdn.dotmaui.com/dotmaui/js/myscript.min.js",
"size": 9465,
"UID": "0gppr1"
}
Examples
import urllib.parse
import urllib.request
js_string = """
var x = myFunction(4, 3); // Function is called, return value will end up in x
function myFunction(a, b) {
return a * b; // Function returns the product of a and b
}
"""
params = urllib.parse.urlencode({'apikey': 'YOUR_API_KEY', 'js': js_string}).encode("utf-8")
minified = urllib.request.urlopen("https://api.dotmaui.com/client/1.0/jsmin/", data = params).read().decode("utf-8")
print(minified) # var a=b(4,3);function b(a,b){return a*b;}
<?php
$data = array('apikey' => 'YOUR_API_KEY',
'url' => "https://dotmaui.com/assets/js/global.js");
$curl = curl_init("https://api.dotmaui.com/client/1.0/jsmin/");
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
$output = curl_exec($curl);
curl_close($curl);
echo $output;
<?php
$field_string = "apikey=YOUR_API_KEY"
. "&url[]=https://cdnjs.cloudflare.com/ajax/libs/modernizr/2.8.3/modernizr.js"
. "&url[]=https://code.jquery.com/jquery-3.2.1.js"
. "&url[]=https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.js";
$curl = curl_init("https://api.dotmaui.com/client/1.0/jsmin/");
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $field_string);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
$output = curl_exec($curl);
curl_close($curl);
echo $output ;