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

How to combine (minify) compiled Angular 2 components?

trying to minify compiled source code of a project for production, I'm using Gulp as the task runner. the source files look like this, html
user5170375
24
votes
2 answers

External source maps for minified, transpiled ES6 code with webpack and gulp

I'm writing ES6 code and transpile it to ES5 with Babel, then minify with Uglify. All run with webpack via gulp. I would like to use external source maps (to keep filesize as small as possible). The gulp task is pretty basic - all the funky stuff is…
gotofritz
  • 3,341
  • 1
  • 31
  • 47
24
votes
3 answers

Unknown Provider e-provider error while using angularjs and ruby on rails

I have a Rails/AngularJS app which works fine in local development environment. However, when I deployed this app to Amazon Cloud the AngularJS returns this error in the browser console: Unknown provider: eProvider <- e However it works fine on…
SemperFi
  • 2,358
  • 6
  • 31
  • 51
24
votes
4 answers

Failed to load resource: 403 forbidden with .js Optimization

I'm trying to minify my .js and .css files. I've installed the packed Install-Package Microsoft.AspNet.Web.Optimization When ever i active the Optimization with BundleTable.EnableOptimizations = true; I receive this error on the client: Failed to…
24
votes
3 answers

Why do we have newlines in minified JavaScript?

I know about a similar question but it is a tiny bit off from what I am asking here, so please don't flag it as a duplicate. When you see the production version of jQuery, why is there a newline after a while? I downloaded a copy and deleted all the…
Anish Gupta
  • 2,218
  • 2
  • 23
  • 37
23
votes
3 answers

Tools for comparing minimized Javascript files

I need to compare two minimized Javascript files. Most common diff viewers list differences per line, but this isn't useful when the script is compressed to a few lines. Are there any good tools for comparing minimized Javascript files?
Jørgen
  • 8,820
  • 9
  • 47
  • 67
23
votes
4 answers

Is it better to minify javascript into a single bundle for the whole site, or a specific-to-each-page bundle?

When minifying JavaScripts together in web-development, is it better from the user-loading-time point of view to: make one single big bundle of JavaScript containing all the script, and include this on each page - so each page will probably not…
Peter Mounce
  • 4,105
  • 3
  • 34
  • 65
23
votes
2 answers

Why using jquery map?

Why using jquery.min.map if: jquery = 242 ko jquery.min + jquery.min.map = 83 + 125 = 208 ko (the map is even greater than the library) And if we remove the comments, we will get a small jquery that could be easier to read (and to debug). So, why…
Abdelouahab
  • 7,331
  • 11
  • 52
  • 82
22
votes
6 answers

Minify jQuery based js files

We are using jQuery in our project. We have numerous custom javascript files in our web-app that have UDFs utilizing the jQuery features. We need to reduce the size (as a part of performance improvement activities) and I am looking for a reliable…
Vini
  • 8,299
  • 11
  • 37
  • 49
22
votes
11 answers

Is there an advanced CSS minifier/compiler that does things like strip redundancy and comma separate identical rules?

For example input{margin:0}body{margin:0;background:white} would be shorter written like this input,body{margin:0}body{background:white} or this input,body{margin:0}body{margin:0;padding:0} would be shorter written like…
700 Software
  • 85,281
  • 83
  • 234
  • 341
22
votes
2 answers

HTML Minification in C#

Tried searching around for a complete library for HTML Minification in C# but haven't been able to locate anything that is useful ? Does anyone here have such a library or know of one ?
Tom
  • 223
  • 1
  • 2
  • 4
22
votes
3 answers

What is the best way to get minified CSS output from LESS?

Is it possible to get minified compiled CSS from LESS automatically? Every time I change something, I have to manually compress it. I use less.js to compile LESS. Thanks.
Jay
  • 405
  • 1
  • 3
  • 12
22
votes
4 answers

Javascript minification why is false replaced with !1 and true with !0

I'm writing an app using Enyo2 which comes with a minification tool based on UglifyJS. I've noticed that: var t = false is replaced with var t=!1 The same way true is replaced with !0. I'm sure there is a good explanation for that, I just can't…
Arek S
  • 4,239
  • 4
  • 24
  • 33
22
votes
3 answers

Maven plugin to concat and minify javascript

I have 100s of javascript files inside the hierarchy of folders and I want two sets of output. one is to have a concatenated version for debugging purposes and the other one is to have a concat + minfy version. I am currently using the below plugin…
Mady
  • 5,016
  • 7
  • 35
  • 46
22
votes
10 answers

Is there such a thing as a javascript deminifier (deobfuscator)?

This question is exactly the opposite of Which Javascript minifier (cruncher) does the same things that the one Google uses for its JS APIs? I want to learn how google does it's loading so I can build my own with non-popular JS toolkits.
Jorge Vargas
  • 6,712
  • 7
  • 32
  • 29