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
47
votes
10 answers

How to minify JS or CSS on the fly

How to minify JS and CSS on the fly / runtime, so that I can keep the original code structure in my servers if its minified on the runtime / fly.
gourav
  • 1,397
  • 5
  • 20
  • 31
47
votes
12 answers

Exclude debug JavaScript code during minification

I'm looking into different ways to minify my JavaScript code including the regular JSMin, Packer, and YUI solutions. I'm really interested in the new Google Closure Compiler, as it looks exceptionally powerful. I noticed that Dean Edwards packer has…
Tauren
  • 26,795
  • 42
  • 131
  • 167
47
votes
5 answers

Does minifying and concatenating JS/CSS files, and using sprites for images still provide performance benefits when using HTTP/2?

With the new HTTP/2 protocol the overhead created by repeated HTTP requests to the same server has been greatly reduced. With this in mind, are there still any significant performance advantages to minifying and concatenating JavaScript/CSS files,…
Alex
  • 5,759
  • 1
  • 32
  • 47
47
votes
1 answer

Tools to optimize (remove redundancy and merge) CSS?

I'm searching for a good CSS compress, merge and optimization tool. I have found tools that clean the CSS but they don't optimize the overwrites. Here is a basic example: a{color:#000} and on another line the a color is overwritten with…
Lucian Povatanu
  • 609
  • 1
  • 5
  • 7
45
votes
2 answers

Google Closure minifier online?

Has anyone setup an online copy/paste utility for Google's Closure minifier? I'm working on a project and I want to minify part of the code manually without having to setup the entire project on my own.
Geuis
  • 41,122
  • 56
  • 157
  • 219
45
votes
6 answers

Why people minify assets and not the HTML?

Why do people suggest minifying web assets, such as CSS and JavaScript, but they never suggest the markup be minified? CSS and JavaScript can be used on many various pages while the markup gets loaded each and every time, making minification of…
austin cheney
43
votes
7 answers

How to force Chrome debugging tools to debug in pretty code?

Although I used pretty code and had set up the breakpoints in "Pretty code" tab, debugger keeps working in minified code. (I can't see exactly where I am and need to continuously switch between source and "pretty code"). On same pages with same…
41
votes
1 answer

Is there any point of using "return !0" in javascript?

If you go to a google result page, and run rwt.toString(), you'll see that the return call for this function is: return !0; I can't think of any reason why this wouldn't always be true. Is this just a shorthand for true, or is there more going on…
Darth Egregious
  • 18,184
  • 3
  • 32
  • 54
40
votes
2 answers

Minify indented JSON string in .NET

I have an indented JSON string e.g. { "a": 1 } However, I don't have the type of the instance to be serialized or deserialized. In my situation, what's the most efficient way to minify a JSON string? e.g. {"a":1} I don't mind using libraries if…
maxbeaudoin
  • 6,546
  • 5
  • 38
  • 53
40
votes
4 answers

Finding the cause of "Unknown provider" errors

I'm getting the following error: Error: [$injector:unpr] Unknown provider: nProvider <- n I know this is being caused by the minification process and I understand why. However is there an easy way to determine which file is actually causing the…
Brett Postin
  • 11,215
  • 10
  • 60
  • 95
40
votes
3 answers

Why would Google use a font tag?

So, I couldn't help noticing while demonstrating Chrome's DOM browser thing to my brother, that Google uses a tag. I know this is a stupid question, but from a programming point of view--why would they use a deprecated tag on Google?…
Carson Myers
  • 37,678
  • 39
  • 126
  • 176
39
votes
5 answers

Minify HTML output from an ASP.Net MVC Application

This is likely a duplicate of the below question but the only answer is a dead link: Minify Html output of ASP.NET Application When working with ASP.Net one of the more annoying aspects to me is the fact that Visual Studio puts spaces instead of…
mynameiscoffey
  • 15,244
  • 5
  • 33
  • 45
39
votes
10 answers

jQuery compiled with Google Closure Compiler

Has anyone compiled jQuery against Google's newly-released Closure compiler? There has been reported huge savings in code size. I'm curious what the benefit is if jQuery was compiled with it.
Ted
  • 555
  • 2
  • 5
  • 5
38
votes
9 answers

How to effectively debug minified JS files?

I've got problem debugging minified JS on production server. While you can't catch some errors on your machine while testing dev/prod servers, there's an opportunity to send some frontend errors and exceptions from users to a special log. When JS…
Sergey Solomatin
  • 657
  • 1
  • 6
  • 12
38
votes
4 answers

How to Minify CSS with SCSS File Watcher in PHPStorm IDE

Is there a way to configure SASS FileWatcher so it builds a Minified CSS? I currently configured SASS + YUI Compressor to accomplish this but I would like to do this with pure SASS if possible. Here are the screenshots of both…
achucuan
  • 387
  • 1
  • 3
  • 8