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

How can I minify HTML with Twig?

I'm using Twig and I'd like to be able to minify the HTML output. How do I do this? I tried {% spaceless %}, but that requires adding that to all my templates. Can I add minification within the Twig engine?
daviesgeek
  • 819
  • 3
  • 14
  • 30
19
votes
8 answers

javascript minification that removes licenses?

Javascript minification will generally remove all comments from source. This means that license information is also removed. If I run a big site, and I want to abide by licenses, does that mean that I cannot use automatic minification? There is no…
mkoryak
  • 57,086
  • 61
  • 201
  • 257
19
votes
1 answer

Does minifying impact performance of Node.js?

In Browsers minifying and concating or loading asynchronous JavaScript has a positive performance impact. Is this also true for code running in Node.js? As Example would excessive commenting and using long names for properties of classes that are…
Kai
  • 228
  • 3
  • 9
19
votes
6 answers

How to minify JS in PHP easily...Or something else

I've done some looking around, but I'm still confused a bit. I tried Crockford's JSMin, but Win XP can't unzip the executable file for some reason. What I really want though is a simple and easy-to-use JS minifier that uses PHP to minify JS…
RickyAYoder
  • 963
  • 1
  • 13
  • 29
18
votes
3 answers

Script Minification and Continuous Integration with MSBuild

On a recent project I have been working on in C#/ASP.NET I have some fairly complicated JavaScript files and some nifty Style Sheets. As these script resources grow in size it is advisable to minify the resources and keep your web pages as light as…
18
votes
4 answers

Uglify-js doesn't mangle variable names

Trying to prepare good build environment for my js library. According to reviews on the web UglifyJS seems to be one of the best compressing modules out there, working under NodeJS. So here is best recommended way of minifying the code: var jsp =…
jayarjo
  • 16,124
  • 24
  • 94
  • 138
18
votes
6 answers

Is there any reason why MicrosoftAjax.js is not minified?

I compress my own JS using YuiCompressor, but is there any reason why MicrosoftAjax.js not minified? Or is there some setting to say run the compressed version of it (if there is a compressed version). Or do I need to decompile it and minify the…
nickytonline
  • 6,855
  • 6
  • 42
  • 76
17
votes
4 answers

Is there such thing as a JSP minifier? (or Open Source HTML minifier)

This would be an HTML minifier that skips everything between <% and %>. Actually, an Open Source HTML minifier would be a good starting place, especially if it already had code to preserve the contents certain blocks like
700 Software
  • 85,281
  • 83
  • 234
  • 341
17
votes
2 answers

How do you build, bundle & minify ES6-modules?

Due the fact, that ES6-modules (JavaScript-modules) are available for testing: https://www.chromestatus.com/feature/5365692190687232 https://medium.com/dev-channel/es6-modules-in-chrome-canary-m60-ba588dfb8ab7 I wonder, how should I minify and…
user8245660
17
votes
5 answers

Integrate Google closure compiler with Eclipse IDE?

Does anybody know how to integrate Google closure compiler with Eclipse IDE? The thing I was trying to do is to configure Google closure compiler as a external tool for Eclipse IDE. Then I would be able to run closure compiler within IDE and minify…
Borivojević
  • 368
  • 2
  • 5
  • 12
17
votes
8 answers

Is there any point to JavaScript minification if you have compression turned on?

If your website has deflate/zip compression enabled is there any point to JavaScript minification? My theory is that the difference between a compressed minified JavaScript file and a compressed unminified JavaScript file is negligible. There are…
Guy
  • 65,082
  • 97
  • 254
  • 325
17
votes
9 answers

jquery-min version?

I noticed that there is always a "min" version (stands for mini?) for most JavaScript libraries (e.g., jQuery). What is the difference? Less functionality but smaller size? Is this something someone should consider using? (There are a lot of min…
ajsie
  • 77,632
  • 106
  • 276
  • 381
17
votes
1 answer

Concatenating multiple statements using Commas vs Semi colons

While working with minified Jquery I noticed multiple statements concatenated by commas. For Example event.preventDefault(); event.stopPropagation(); jQuery.event.trigger( event, data, this[0] ); return event.result; minified…
loxxy
  • 12,990
  • 2
  • 25
  • 56
17
votes
5 answers

Put javascript and css inline in a single minified html file to improve performance?

A typical website consists of one index.html file and a bunch of javascript and css files. To improve the performance of the website, one can: Minify the javascript and css files, to reduce the file sizes. Concatenate the javascript files into one…
Jos de Jong
  • 6,602
  • 3
  • 38
  • 58
17
votes
6 answers

how to compress and minify assets using jekyll plugins

I have a simple test jekyll app like so: index.html is: