Speed up ASP.NET with Minify & Merge JavaScript

Dramatically improve ASP.NET response times by reducing the number of HTTP calls your browser makes to IIS and also reducing the size of JavaScript and CSS being used in your ASP.NET pages.

ASP.NET applications have to deal with extra overhead of loading multiple CSS and JavaScript files. Whenever a page is being rendered in the browser, the browser issues separate GET calls for each JavaScript and each CSS file. And, this can easily result into many extra calls to IIS and slow down the response time of the ASP.NET pages in SharePoint.

Why Minify & Merge JavaScript Files?

JavaScript Minification is a process in which NCache reduces the size of all CSS and JavaScript files. JavaScript merge is a process in which NCache merges all JavaScript files into one file. As a result, a web browser only makes one GET call to IIS for loading all the JavaScript and one for CSS. Here are some reasons why you should minify JavaScript and CSS and merge JavaScript files:

  • Reduce number of HTTP requests a browser makes
  • Set a futuristic date so browser caches files longer
  • Minify JavaScript and CSS files and reduce their payload size
  • Merge multiple JavaScript and CSS files into one
  • Boost response time of ASP.NET web pages

How does NCache Minify JavaScript and CSS?

NCache reduces the size of all JavaScript and CSS files by going through and removing all white spaces, tabs, and any other extra characters. It also reduces names of local variables and parameters but ensures that no logic is broken. Below is an example of a typical JavaScript function and then how it looks after it is minified.

function AddMPOverhang(leftOverhangId, rightOverhangId) 
  var leftOverhang=document.getElementById(leftOverhangId);
  var rightOverhang=document.getElementById(rightOverhangId);

  if (leftOverhang !=null && !=null) {'relative';'-7px';

  if (rightOverhang !=null && !=null) {'relative';'-7px';

Below is the same JavaScript function after it has been minified.

function AddMPOverhang(C,D)
  var B=document.getElementById(C);
  var A=document.getElementById(D);

  if(B!=null&&!=null) {"relative";"-7px"

  if(A!=null&&!=null) {"relative";"-7px";

In addition to reducing the size of all JavaScript and CSS files, NCache also merges multiple files into one so the browser has to only download one or two files at most (one for JavaScript and one for CSS). This reduces the number of HTTP requests a browser has to make for loading an ASP.NET page and improves performance and scalability of SharePoint WFE server farm.

What to Do Next?