Online javascript code minification tool for free
What is this Tool?
This is a javascript minifier. A lot of the time, javascript code will contain numerous unnecessary things such as line-breaks, comments, spaces, inlines, etc all which make it readable for humans, but will contribute to slower page loading. Through this tool, you can remove all of that while keeping performance the same, ensuring webpages will load faster.
Minification is a method recommended by multiple developers and even PageSpeed Insights, a popular utility tool made to verify a website page loading performance. Researches show that, pages that load even slightly faster tend to have higher conversion rates, generating more clicks, retaining users for longer and inevitably making more money.
Examples
Here’s a good example of un-minified code:
let variable=true;
function doWork(){
if(variable==true){
alert("it is true!")
}else{
console.log("it was false")
}
}
now lets run this through the minifier to see how it’ll look:
let variable=!0;function doWork(){1==variable?alert("it is true!"):console.log("it was false")}
As you can see, now the code uses just one line, true was replaced by !0, which has the same meaning in javascript but uses 2 characters instead of 4, the if statement got changed from “== true” to “==1” which again, will have the same result but uses less characters, etc.
The end result of the minification is difficult to read for humans, which can be positive, as it works as a way to obfuscate the code, making it harder for it to be stolen or modified by others, but for the javascript interpreter, it will execute just the same, while consuming 28% less data to be downloaded.