Back to home
ManualLinter - Tom Hermans
Manual Linter brings all your assets (html, css, and js) into one html file, and throws a few optimizations in the mix as well.
Adapts some bits from xem's miniMinifier .
HTML
NOTE: The syntax to match the "style" and "script" tags is very strict. You can see an example below (if the text field is empty).
CSS (remove most spaces, newlines, and comments). Will replace any stylesheet links with embedded css in style tags
Javascript (only up a few files at the moment! The minifier is also pretty strict, turn it off below if you're having issues with it.)
Minify CSS
Minify all JS code (experimental!)
Combine consecutive 'script' calls into one (experimental!)
Lint!
Output
Just the Javascript code (for further minification):
',"\n\n");
htmlmin = htmlmin.replace('',"\n\n");
htmlmin = htmlmin.replace('',"\n\n");
htmlmin = htmlmin.replace('',"\n\n");
htmlmin = htmlmin.replace('',"\n\n");
} else {
htmlmin = htmlmin.replace('', "\n', js2+"\n");
htmlmin = htmlmin.replace('', js3+"\n");
htmlmin = htmlmin.replace('', js4+"\n");
htmlmin = htmlmin.replace('', js5+"<\/script>\n");
}
output.value = htmlmin;
jsoutput.value = js1 + "\n" + js2 + "\n" + js3 + "\n" + js4 + "\n" + js5;
percent = (((chars - htmlmin.length) / chars) * 100).toFixed(2);
stats.innerHTML = "Went from "+chars.toString()+" characters down to "+htmlmin.length.toString()+", a save of "+percent.toString()+"%";
}
function striphtml(string) {
var temp = string;
temp = temp.replace(/(\r\n|\n|\r)/gm, ""); //Remove newlines
temp = temp.replace(/ /g,"") //Remove spaces
temp = temp.replace(/\t/g, ''); //Remove tabs
return(temp)
}
function stripcss(string) {
if (!css_minify.checked) {
return string;
}
var temp = string;
temp = temp.replace(/(\r\n|\n|\r)/gm, ""); //Remove newlines
temp = temp.replace(/ /g,"") //Remove spaces
temp = temp.replace(/\/\*[\s\S]*?\*\/|([^\\:]|^)\/\/.*$/gm, '$1'); //Remove comments
temp = temp.replace(/\t/g, ''); //Remove tabs
return(temp);
}
function stripjs(string) {
if (!js_minify.checked) {
return string;
}
var temp = string;
temp = temp.replace(/\/\*[\s\S]*?\*\/|([^:]|^)\/\/.*$/gm, '$1'); //Remove comments
temp = temp.replace(/(\r\n|\n|\r)/gm, " "); //Remove newlines
temp = temp.replace(/ /g, ''); //Remove spaces
temp = temp.replace(/\t/g, ''); //Remove tabs
temp = temp.replace(/ = /g,"=") //Remove spaces
temp = temp.replace(/ { /g,"{") //Remove spaces
temp = temp.replace(/ } /g,"}") //Remove spaces
temp = temp.replace(/{ /g,"{") //Remove spaces
temp = temp.replace(/} /g,"}") //Remove spaces
temp = temp.replace(/ {/g,"{") //Remove spaces
temp = temp.replace(/ }/g,"}") //Remove spaces
temp = temp.replace(/; /g,";") //Remove spaces
//temp = temp.replace(/: /g,":") //Remove spaces
temp = temp.replace(/if \(/g,"if(") //Remove spaces
temp = temp.replace(/ == /g,"==") //Remove spaces
temp = temp.replace(/ != /g,"!=") //Remove spaces
temp = temp.replace(/ && /g,"&&") //Remove spaces
temp = temp.replace(/ \|\| /g,"||") //Remove spaces
return(temp);
}