Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JavaScript code compression

Tags:

javascript

Is there is way to compress JavaScript code?

e.g.

function test(){
  // some code here 
}

after compression it should be

function test(){//some code here} 

Also, I need vise versa at the time of editing the code.

like image 980
Vicky Avatar asked Jan 29 '10 05:01

Vicky


People also ask

Should I compress JavaScript?

It is important to minify your CSS and minimise JavaScript files so they can load faster on your web pages. There are many reasons why you should minify your CSS and JavaScript: Reduce file size: The more code there is in a file, the larger it will be. Minified code is usually much smaller than the original version.

Is minified JavaScript faster?

Minification does improve performance for two reasons: Reduced file-size (because it removes comments and unnecessary white spaces), so your script loads faster.

Why do we minify JavaScript?

Minification is the process of minimizing code and markup in your web pages and script files. It's one of the main methods used to reduce load times and bandwidth usage on websites. Minification dramatically improves site speed and accessibility, directly translating into a better user experience.


1 Answers

You can use a javascript minifier.

YUI Compressor

JS Minifier

jsCompress

like image 100
rahul Avatar answered Sep 28 '22 15:09

rahul