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
1
vote
1 answer

Requirejs optimiser - module setup fails to skip external sources

I'm currently trying to create separate modules within the requirejs optimiser config which currently looks like: Module based setup (fails to skip facebook path): ({ baseUrl: '../static/js', mainConfigFile: '../static/js/main.js', …
Malcr001
  • 8,179
  • 9
  • 44
  • 57
1
vote
1 answer

Tomcat minification cancelled by ISAPI/IIS

I have a website running on a server with Tomcat (port 8080) and IIS (6). I've implemented the webutilities filter from Google (to minify resource files) and added it to the web.xml file of my project (WEB-INF/web.xml). When I access a resource-file…
sempervirescent
  • 153
  • 1
  • 8
1
vote
1 answer

How to serve sourceMappingURL files?

Currently I am serving sourceMappingURL files with following contenttype: Content-type:text/javascript; charset=utf-8 Is this correct? It works, but I don't know, if it is correct. What other headers should I send along with it?
Christian
  • 3,503
  • 1
  • 26
  • 47
1
vote
1 answer

ngmin not working in windows

I am trying to minify all js files (start with controllers and app.js). As we know that regular minifier (uglify etc) won't work directly on angularjs files because of module declaration conventions. So I tried using ngmin for that. Concatenated all…
rahul
  • 3,018
  • 4
  • 29
  • 28
1
vote
0 answers

ASP.NET MVC bundling and minifying without removing new line characters

Using ASP.NET MVC bundling, is it possible to have minified files where the new line characters are not removed? I was looking into JsMinify class, but cannot figure out if that is possible to configure. I want to keep the new line characters for…
Alvis
  • 3,543
  • 5
  • 36
  • 41
1
vote
1 answer

Different merged and minified js files in different htmls in one app

I have an express.js application, it renders pages on server and serves them on different routes - /home and /dashboard etc., for example, I use several js files, some on all pages, some not: on home page I use: jquery.js, underscore.js,…
Kosmetika
  • 20,774
  • 37
  • 108
  • 172
1
vote
1 answer

Are there any benefits to minifying PHP code?

This maybe a very stupid question as PHP is server side programming But if minifying CSS and minifying Javascript (although they are client side) is a good thing to do to optimise for speed, is there such a thing as minifying PHP and would it have…
Liam Sorsby
  • 2,912
  • 3
  • 28
  • 51
1
vote
2 answers

Dean Edwards' php packer not rename var and function

I actually have a js code that i want to protect, and so i use the dean edward's packer php from Nicolas Martin : http://joliclic.free.fr/php/javascript-packer/en/index.php It correctly minify my code, but it doesn't rename var & function name (so…
Jeremy F.
  • 19
  • 2
1
vote
1 answer

Asset Compress Plugin for CakePHP not working

I'm having troubles to compress my Javascript files using Asset Compress Plugin for CakePHP 2.X. I'm currently using CakePHP 2.2.2 over IIS 7. It tries to add the compressed js file but it doesn't exist: