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
22
votes
3 answers

Rails 3 + angularjs + minification does not work in production: Unknown provider: eProvider

I've followed all the instructions I can find for fixing minification, e.g. var MyController = function(renamed$scope, renamedGreeter) { ... } MyController.$inject = ['$scope', 'greeter']; and someModule.factory('greeter', ['$window',…
jemminger
  • 5,133
  • 4
  • 26
  • 47
22
votes
2 answers

How do I split my javascript into modules using Google's Closure Compiler?

I want to use the google closure compiler on the javascript source we're using. In development mode we tend to break functionality to lots of files but for production would like to have them combined into modules. When calling the compiler I can…
Nitzan Tomer
  • 155,636
  • 47
  • 315
  • 299
21
votes
7 answers

Minifying and combining files in .net

I am looking at implementing some performance optimization around my javascript/css. In particular looking to achieve the minification and combining of such. I am developing in .net/c# web applications. I have a couple of options and looking for…
amateur
  • 43,371
  • 65
  • 192
  • 320
21
votes
2 answers

Minify (not transpile) ES2015 code with Gulp

How to minify ES2015 code without transpiling it to ES5? The popular gulp-minify and gulp-uglify modules do not work with simply minifying ES2015 code.
Leon Revill
  • 1,950
  • 3
  • 18
  • 25
21
votes
6 answers

javascript packer versus minifier

I was wondering what the differences/benefits of the packer vs the minifier were, i.e. Should you deploy a packed or minified version in your web app? Example code: var layout = { NAVVISIBLE : 1, Init : function() { …
user318747
  • 1,418
  • 2
  • 16
  • 29
21
votes
7 answers

Reduce HTTP requests or not?

A theoretical question: We all know about the pro's of minifying and combining javascript files in order to reduce HTTP requests to speed up a website. But when popular javascript libraries is used (jQuery for instance), it isn't too stupid to…
Industrial
  • 41,400
  • 69
  • 194
  • 289
21
votes
2 answers

Chrome Dev Tools: View unminified CSS

Perhaps I'm missing something (a toggle perhaps) but is there a way to view the unminified (prettyprint) version of a minified CSS source file in Chrome dev tools?
Scott B
  • 38,833
  • 65
  • 160
  • 266
20
votes
6 answers

Moshi KotlinJsonAdapterFactory cannot parse Json after enabled minify

I have developed an Android app, using Moshi as one of its dependencies. Today I want to enable minify for this project. So I set minifyEnabled true in my build.gradle. After that, I found that all responses from server become null. First of all, I…
Sira Lam
  • 5,179
  • 3
  • 34
  • 68
20
votes
6 answers

Failed to minify the code from this file

I am authoring a JavaScript library that I want to put on npm. I am currently using that library in another project and I have added it as a dependency using its GitHub repository: "dependencies": { // ... others "react-web-component":…
Lukas
  • 9,752
  • 15
  • 76
  • 120
20
votes
4 answers

Can I get Webpack to bundle but without minification for debugging?

Seems like a truly stupid question that must have an answer somewhere, but I've searched for hours to no avail. I'm new to ReactJS and building with Webpack, build configs in general. I'm using Webpack to link and bundle my entire project,…
Steverino
  • 2,099
  • 6
  • 26
  • 50
20
votes
3 answers

Why does minified or obfuscated JavaScript perform worse than uncompressed code?

I came across this performance report of JavaScript code compressed using various minifiers and obfuscators. What is surprising is that apart from Closure advanced mode, in most cases all other minifiers output code that performs worse than…
Dheeraj Vepakomma
  • 26,870
  • 17
  • 81
  • 104
20
votes
2 answers

Is it bad to Base62 encode a javascript file?

I just found Dean Edwards javascript packer here: http://dean.edwards.name/packer/ It has a couple of options, Base62 encode Shrink variables To test it I took the latest version of jquery that is already minified to 56kb and ran it on that…
JasonDavis
  • 48,204
  • 100
  • 318
  • 537
20
votes
3 answers

Why does Closure Compiler insist on adding more bytes?

If I give Closure Compiler something like this: window.array = '0123456789'.split(''); It "compiles" it to this: window.array="0,1,2,3,4,5,6,7,8,9".split(","); Now as you can tell, that's bigger. Is there any reason why Closure Compiler is doing…
qwertymk
  • 34,200
  • 28
  • 121
  • 184
19
votes
3 answers

Does it make sense to do both minify and uglify?

Given that uglification involves some minification in the process, does it still make sense to do both minify and uglify? If yes, should one minify or uglify first? Is it enough to do uglify only? Will the code be more obfuscated if both are done?
guagay_wk
  • 26,337
  • 54
  • 186
  • 295
19
votes
4 answers

Javascript error Unknown provider: tProvider <- t after Rails minification Angularjs

My Rails app doesn't work after turned on assets magnification when assets compiled. I converted the Angular controllers to use the bracket notation, and get following error, is there a way to debug this? Compiled application.js…
user1883793
  • 4,011
  • 11
  • 36
  • 65