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
437
votes
17 answers

Tool to Unminify / Decompress JavaScript

Are there any command line scripts and/or online tools that can reverse the effects of minification similar to how Tidy can clean up horrific HTML? (I'm specifically looking to unminify a minified JavaScript file, so variable renaming might still be…
Andy Ford
  • 8,410
  • 3
  • 26
  • 36
310
votes
12 answers

What's the difference between jquery.js and jquery.min.js?

What is the difference between jquery.min.js and jquery.js? Which one has support for all functions?
gowri
  • 3,103
  • 2
  • 17
  • 7
297
votes
5 answers

sass --watch with automatic minify?

Is there a way to run: sass --watch a.scss:a.css but have a.css end up being minified? How would I avoid having to run a separate minification step as I compile my stylesheet?
tester
  • 22,441
  • 25
  • 88
  • 128
292
votes
21 answers

Any recommendations for a CSS minifier?

Any recommendations for a CSS minifier? I’ll be rooting around Google and trying some out, but I suspected that the smart, proficient and curiously handsome StackOverflow community might have already evaluated the pros and cons of the heavyweights.
Paul D. Waite
  • 96,640
  • 56
  • 199
  • 270
248
votes
2 answers

Excluding files/directories from Gulp task

I have a gulp rjs task that concatenates and uglifies all my custom .JS files (any non vendor libraries). What i am trying to do, is exclude some files/directories from this task (controllers and directives). Heres my tree: - application -…
Oam Psy
  • 8,555
  • 32
  • 93
  • 157
158
votes
15 answers

How to minify php page html output?

I am looking for a php script or class that can minify my php page html output like google page speed does. How can I do this?
m3tsys
  • 3,939
  • 6
  • 31
  • 45
137
votes
13 answers

Gzip versus minify

I had a somewhat lively discussion the other day about minifying Javascript and CSS versus someone who prefers using Gzip. I'll call this person X. X said that Gzip allready minifies the code, since it zips your files. I disagree. Zip is a lossless…
KdgDev
  • 14,299
  • 46
  • 120
  • 156
135
votes
9 answers

Is there a good JavaScript minifier?

What JavaScript minifier do you recommend?
user160820
  • 14,866
  • 22
  • 67
  • 94
126
votes
11 answers

How do you automate Javascript minification for your Java web applications?

I'm interested in hearing how you prefer to automate Javascript minification for your Java web apps. Here are a few aspects I'm particularly interested in: How does it integrate? Is it part of your build tool, a servlet filter, a standalone program…
gustafc
  • 28,465
  • 7
  • 73
  • 99
124
votes
3 answers

Is it possible to compile TypeScript into minified code?

Is there an option to compile TypeScript code's output as minified? Or are we left to deal with that in a separate process? And does obfuscation affect the answer?
LordZardeck
  • 7,953
  • 19
  • 62
  • 119
111
votes
8 answers

Is there a point to minifying PHP?

I know you can minify PHP, but I'm wondering if there is any point. PHP is an interpreted language so will run a little slower than a compiled language. My question is: would clients see a visible speed improvement in page loads and such if I were…
Bojangles
  • 99,427
  • 50
  • 170
  • 208
105
votes
13 answers

Uncaught TypeError: undefined is not a function on loading jquery-min.js

I'm building a normal webpage which requires me to load about five CSS files and ten Javascript files. When loading them separately in the HTML page, my webpage loads fine. Now for production, I concatenated all the Javascript into a single file,…
ghostCoder
  • 1
  • 9
  • 49
  • 72
99
votes
8 answers

HTML minification?

Is there a online tool that we can input the HTML source of a page into and will minify the code? I would do that for aspx files as it is not a good idea to make the webserver gzip them...
Paulo
  • 7,123
  • 10
  • 37
  • 34
98
votes
5 answers

How to concatenate and minify multiple CSS and JavaScript files with Grunt.js (0.3.x)

Note: This question is only relevant for Grunt 0.3.x and has been left for reference. For help with the latest Grunt 1.x release please see my comment below this question. I'm currently trying to use Grunt.js to setup an automatic build process for…
Jasdeep Khalsa
  • 6,740
  • 8
  • 38
  • 58
93
votes
9 answers

How can I estimate the size of my gzipped script?

How can I estimate the size of my JavaScript file after it is gzipped? Are there online tools for this? Or is it similar to using winzip for example?
Christophe
  • 27,383
  • 28
  • 97
  • 140
1
2 3
99 100