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
29
votes
4 answers

How to minify CSS and JavaScript files in Visual Studio 2015

I am building a web application for mobile using visual studio, and I wanted to know how do I minify all my CSS files into one file, and also all my JavaScript to one minified file.
Bergerova
  • 863
  • 3
  • 10
  • 21
29
votes
8 answers

Best way to combine and minify JS / CSS on Heroku

First of all, according to this answer, the :cache => true option on stylesheet_link_tag and javascript_include_tag doesn't work on Heroku. Is this true? I've found :cache => true to work occasionally, but not always (weird!) Also, what's the best…
Tom Lehman
  • 85,973
  • 71
  • 200
  • 272
28
votes
8 answers

Retrofit body request is blank with Retrofit, when I use proguard and enable minify and shrinkresources

When I set minifyEnabled & shrinkResources to true,the Retrofit body JSON request sent is blank, and when it is set to false then it works perfectly fine. I have posted the whole gradle file so that, you can help me telling what I am doing wrong. My…
Salman Shaikh
  • 589
  • 6
  • 19
28
votes
6 answers

Django: auto minifying css/js files before release

I have following case: I want to use uncompressed js/css files during development (to debug js for example) but on production I want to switch automatically to minified versions of that files. some simple solution is to put in your template:
dzida
  • 8,854
  • 2
  • 36
  • 57
28
votes
4 answers

Minify/compress CSS with regex?

In PHP can you compress/minify CSS with regex (PCRE)? (As a theoretical in regex. I'm sure there are libraries out there that do this well.) Background note: After spending hours writing an answer to a deleted (half crap) question, I thought I'd…
Qtax
  • 33,241
  • 9
  • 83
  • 121
27
votes
7 answers

Remove unused javascript code based on coverage report

There is a big javascript library (~ 40 000 lines of code) and an application which uses less than 50% of the library's code. There is a test which utilizes all the needed functionality from the library and can produce coverage report. How to remove…
Oleg Mikhailov
  • 5,751
  • 4
  • 46
  • 54
27
votes
6 answers

Is minifying your HTML, CSS, and Javascript a bad idea?

Wikipedia defines minification as... [...] the process of removing all unnecessary characters from source code without changing its functionality. These unnecessary characters usually include white space characters, new line characters, comments,…
JohnCand
  • 1,197
  • 2
  • 12
  • 19
26
votes
4 answers

Better to combine & minify javascript or use Google CDN?

I am building a site which currently uses javascript from several sources: Group 1: Google Maps API v3 (hosted by Google) Group 2: jQuery & swfobject (hosted on Google CDN) Group 3: Several jQuery plugins and non-jquery javascript files (hosted on…
jessegavin
  • 74,067
  • 28
  • 136
  • 164
26
votes
5 answers

Using twitter's bootstrap in jsFiddle

I would like to use Twitter's Bootstrap in one of my fiddles. Since jsFiddle does not offer bootstrap as one of its pre-defined libraries, I am looking for a minified url. Is there a free minified URL for Twitter's Bootstrap?
Adam Matan
  • 128,757
  • 147
  • 397
  • 562
26
votes
2 answers

Do the parameters of a directive's link function rely on DI?

In: module.directive 'name', -> (scope, element, attr) -> # Whatever implemenation Do the scope, element and attrs parameters of the link function rely on name-inferred Dependency-Injection? If yes, how can I make them minification proof ? Or…
ejoubaud
  • 5,013
  • 6
  • 37
  • 39
26
votes
5 answers

Minifying code for PhoneGap App?

I am currently starting to build an PhoneGap application, I know the advantages of minifying code for browsers already. However, I was wondering if it was worth minifying my HTML, JavaScript and CSS code for my PhoneGap application? I would…
Nick White
  • 1,602
  • 4
  • 20
  • 35
25
votes
7 answers

How to minify/obfuscate a bash script

Of course a bash file cannot be truly obfuscated and will always be readable. And I don't want to wrap them in some binary package. And renaming local variables wouldn't be worth the trouble. But is there a reliable simple bash obfuscator or…
Christian
  • 2,903
  • 4
  • 31
  • 34
25
votes
3 answers

How to deminify javascript

Possible Duplicate: Online Tool to Unminify / Decompress JavaScript Tool to reverse Javascript minify? Is there a way to convert minified JavaScript code into normal?
eomeroff
  • 9,599
  • 30
  • 97
  • 138
25
votes
1 answer

How do I minify dynamic HTML responses in Spring?

Following Google's pagespeed advice I would like the minify the HTML responses of my Spring application. I don't mean GZip, I mean removing comments and whitespace from HTML before it is sent down the wire. I would like to do this dynamically and…
JackMahoney
  • 3,423
  • 7
  • 32
  • 50
25
votes
1 answer

Why does Google's Closure Compiler leave a few unnecessary spaces or line breaks?

I've noticed that every time I use Google's Closure Compiler Service, it leaves a few unnecessary spaces in the compiled code presented on the right-hand side of the page. These correspond to line breaks in the hosted version of the compiled…
Bungle
  • 19,392
  • 24
  • 79
  • 106