Questions tagged [minify]

Minification is the practice of removing unnecessary characters from code to reduce its size, thus improving load times.

A minifier is a tool to perform minification on set of text, most notably source code. In web development, page load times are important, so reducing the file size of JavaScript source files helps reduce the time it takes for the code to be downloaded over an Internet connection.

Minification is the practice of removing unnecessary characters from code to reduce its size. For developmental purposes, programmers use whitespace characters (spaces, tabs, carriage returns, etc.) to format source code in a way that is easier for humans to read.

The computers and software that consumes this code does not care at all about how it is formatted, so removing these characters will not alter the code's functionality at all.

Un-minified Example:

var myArray = [];
for (var i = 0; i < 20; i++) {
  myArray[i] = i;
}

Minified Example:

for(var a=[i=0];++i<20;a[i]=i);

Both of the examples perform the same task of iterating through 20 numbers and adding them to an array.

In addition to whitespace removal, minifiers will also rename variables to shorter names and possibly refactor some logic in ways that yield the same outcome.

2450 questions
37
votes
4 answers

How do I concatenate and minify files using webpack

I want to be able to minify and concatenate files to 1 single file without using grunt How to concatenate and minify multiple CSS and JavaScript files with Grunt.js (0.3.x) can I achieve this with just webpack? I tried many different combinations…
Binh Phan
  • 381
  • 1
  • 3
  • 3
37
votes
3 answers

Why does JS minification convert 1000 to 1E3?

What is the point to change (int) 1000 to 1E3? And where does 1E3 come from? I know just 3bytes vs 4bytes.
l2aelba
  • 21,591
  • 22
  • 102
  • 138
37
votes
6 answers

Minify Html output of ASP.NET Application

What are the ways by which we can reduce the size of the HTML Response sent by an asp.net application? I am using Controls which are not owned by me and it produces output with white spaces. I am interested in Minifying the entire HTML output of the…
Ramesh
  • 13,043
  • 3
  • 52
  • 88
36
votes
2 answers

AngularJS: Correct minify-able syntax when using resolve with controllers

I'm using the resolve functionality with a couple of controllers to fetch some data before the rendering of a new view kicks in like this: HomeCtrl.resolve = { pictures: function(Picture) { return Picture.getall(); } }; How do I…
acrmuui
  • 2,040
  • 1
  • 22
  • 33
35
votes
5 answers

How can I minify JSON in a shell script?

I've been looking for a way to uglify some JSON while in my bash console. This help using it afterward in another command (for example, to pass json inline to httpie) Giving: { "foo": "lorem", "bar": "ipsum" } I want to…
Ulysse BN
  • 10,116
  • 7
  • 54
  • 82
35
votes
4 answers

Best javascript compiler/minifier

I remember having seen a new javascript compiler/ minifier on github which should even be better than google's closure compiler. Unluckily I can't remember its name and find it again. Maybe someone can help me? :) Thanks, Corin
gucki
  • 4,582
  • 7
  • 44
  • 56
33
votes
1 answer

Running the same plugin multiple times in Maven

I'm using maven-minify-plugin. It can produce only one output file. I need to produce two minified js files. One from one set of files, the other from another set of files. Can I somehow trick Maven into running two different configurations for the…
Yuri Geinish
  • 16,744
  • 6
  • 38
  • 40
32
votes
6 answers

Elegantly minify dynamically generated javascript in a .NET environment?

I'm programmatically creating javascript files from a .NET web app and would like to minify it before passing it to the client. Is there an efficient technique for doing this?
Hairgami_Master
  • 5,429
  • 10
  • 45
  • 66
32
votes
3 answers

How to minify a Flutter app with Proguard?

I already made a Flutter app. The release apk is about 14MB. I searched methods to minify this and found this ons: https://flutter.io/android-release/#enabling-proguard But my question is, how can I get to know all my used additional libraries for…
Jan D.M.
  • 2,284
  • 2
  • 20
  • 32
32
votes
3 answers

Is there a way to rewrite the HTML to use gulp-minified CSS

I'm struggling with the following: My gulpfile.js compiles all .less, minifies it and concattenates all CSS into ./dist/all.min.css Is there a way I can rewrite the HTML file, remove all style tags and only put one style tag into it loading the…
dlaxar
  • 549
  • 1
  • 4
  • 9
32
votes
2 answers

AngularJS : minification issue in directive

I have yet another issue with minification. This time it's because of the $scope service passed to the directive's controller. See below code: angular.module('person.directives'). directive("person", ['$dialog', function($dialog) { return { …
Sam
  • 13,934
  • 26
  • 108
  • 194
31
votes
5 answers

Is there a benefit to minifying JavaScript before gzipping it?

Is there some valid purpose to minifying before compressing? It seems highly unlikely that the gzipped file is smaller if it's minified first. I ask because diagnosing production problems in minified code is substantially more difficult, and I'm…
Steve Steiner
  • 5,299
  • 4
  • 32
  • 43
31
votes
0 answers

Tool to reverse Javascript minify?

Possible Duplicate: Online Tool to Unminify / Decompress JavaScript Online javascript minify tools basically strip out comments and whitespace. Is there a tool that can reverse this? Taking what is usually a single line of code: function(){var…
Robin Rodricks
  • 110,798
  • 141
  • 398
  • 607
30
votes
4 answers

How do I get the compact/minified form of pretty-printed JSON in Java?

How do I make Jackson's build() method pretty-print its JSON output? is an example that pretty-prints the JSON string. I need to take the pretty-printed version of JSON string and then convert it to the compact/minified form. How can it be done? I…
mtyurt
  • 3,369
  • 6
  • 38
  • 57
29
votes
6 answers

Which Javascript minifier (cruncher) does the same things that the one Google uses for its JS APIs?

I am a Google Maps API (javascript) developer. I have noticed that Google uses a Javascript minifier that has the following features: Shortens variables, properties, arguments, classes, function and method names, obfuscating the code. (eg.…
Jader Dias
  • 88,211
  • 155
  • 421
  • 625