.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

Combine, minify and compress JavaScript files to load ASP.NET pages faster

Posted By: sagar pardeshi     Posted Date: April 02, 2010    Points: 2   Category :ASP.Net
Websites are getting more interactive these days and most of this interactivity comes from JavaScript. People are using different JavaScript libraries and frameworks to make their websites more interactive and user friendly.

View Complete Post

More Related Resource Links

Utility Spotlight: 12 Steps To Faster Web Pages With Visual Round Trip Analyzer


Download Visual Round-trip Analyzer (VRTA) to uncover the root of your Web page loading problems and identify these 12 common ailments.

Jim Pierson

MSDN Magazine November 2008

Zip Your Data: Using the Zip Classes in the J# Class Libraries to Compress Files and Data with C#


Zip compression lets you save space and network bandwidth when storing files or sending them over the wire. In addition, you don't lose the directory structure of folders you Zip, which makes it a pretty useful compression scheme. The C# language doesn't have any classes that let you manipulate Zip files, but since .NET-targeted languages can share class implementations, and J# exposes classes in the java.util.zip namespace, you can get to those classes in your C# code. This article explains how to use the Microsoft J# class libraries to create an application in C# that compresses and decompresses Zip files. It also shows other unique parts of the J# runtime you can use from any .NET-compliant language to save some coding.

Ianier Munoz

MSDN Magazine June 2003

Javascript at the end of aspx files. What is the benefit?

Hello,In one of the examples I saw a call to a JS function at the end of the aspx file.Like the following:<script language="javascript" type="text/javascript">   <!--    SetExternal();   // --></script>I was under the impression that the JS functions are either called on onlclick of button events or in the HTML Body tag with Onload.So when an aspx page loads then do you thin the following function which is at the end of the page will be called? and why do we put these functions at the end of the page?Thanks.

Enhancing ASP.NET Pages with JavaScript

Hi All,         I have a JS coding to change the current menu Image.Ie,The current page will highlighted others having mouse over effect onlyThe js  code is below:===============<script type="text/JavaScript"><!--function MM_swapImgRestore() { //v3.0  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;}function MM_preloadImages() { //v3.0  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}}function MM_findObj(n, d) { //v4.01  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);  if(!x && d.getElementById) x=d.getElementById(n); return x;}function MM_swapImage() { //v3.0  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3) 

Load Javascript/CSS from C# Class Library

Can anyone help me figure out how to load Javascript/CSS from my Class Library onto my .aspx pages? Is it possible?Thanks

How to use GZIP for aspx, css, and javascript files.

Hi all,I have heard that if we use gzip, aspx files will be loading faster. But, I am not sure as to how to use it in my web applications.I am hosting my site with GODADDY (ASP 2, IIS 7)Can anyone tell me if I will be able to use gzip? Can you give me a sample file where gzip is used?Thanking you in advanceTomy

Javascript in Master Pages

Hi,  I am unable to find the value of the texboxes in the code below. arguments.IsValid = false; This statement isn't preventing the code behing to stop.     <%@ Page Language="VB" MasterPageFile="~/MasterPage.master" AutoEventWireup="false" CodeFile="Details.aspx.vb" Inherits="Details" Title="Details" %>       <asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">       <table>      <tr>       <td><asp:TextBox ID="txtFname" runat="server" ValidationGroup="vgSubmit" MaxLength="16"></asp:TextBox></td>      </tr>      <tr>       <td><asp:CustomValidator ID="cvPassword" runat="server" ValidationGroup="vgSubmit" ClientValidationFunction="fnSubmit"></asp:CustomValidator></td>      </tr>      <tr>       <td><asp:Button ID="btnsubmit" runat="server" CssClass="button_class" Tex

How to Combine ScriptResource.axd and WebResource.axd files in ASP.Net 2.0


 Hi All,

Please help me to resolve the below issue

Basically My requirement is  to combine webresource.axd and scriptresource.axd files. 

As you know when we use asp.net ajax and ajaxtoolkit in the application by default , some of the javascript files(webresource.axd and scriptresource.axd) will load automatically. 

For loading all the JavaScript files browser will take multiple requests, To reduce the multiple requests i am trying  to combine all the scripts into one file and loading into the client side. 

I have tried to resolve using custom httpmodule and httphandlers but they are still putting me in loops. 

If i am not using AjaxToolkit Controls my custom httpmodule working fine to combine scriptresource.axd and webresource.axd files

andalso browser taking only one request to get all the javascript files.

if i am using Ajaxtoolkitcontrols i am getting error scriptLoad Failed exception and sys is undefined

I just wanted to knock people to understand if they had used a different method, we could get some help. 

I want to do everything using asp.net 2.0



Too many javascript files loading?


I recently ran yslow on a page i have (master paged etc) and it returned that there were far too many javascript files included (most of which I haven't added).

I guess my question is that given i have v1.0.20229.0 of the toolkit.dll (over .net 2)

I'm wondering if subsequent releases have fixes for this sort of thing?


How to minify html , css , javascript ( removing white spaces etc )


i am looking for a tool which will minify my code when publishing website


or it may be run time minify too if not using too much cpu power



how can i Register multi javascript files with RegisterClientScriptInclude method in OnPreRender


hi friends.

how can i use multi javascript files with RegisterClientScriptInclude method in custom server controls.

when i call two or more  RegisterClientScriptInclude method, this method registers only one of the javascript files.

protected override void OnPreRender(EventArgs e)
            string testJS = Page.ClientScript.GetWebResourceUrl(this.GetType(), "MyControl.js.testJS.js");
            string RichText = Page.ClientScript.GetWebResourceUrl(this.GetType(), "MyControl.js.RichText.js");
            this.Page.ClientScript.RegisterClientScriptInclude(this.GetType(), "MyControl", testJS);
            this.Page.ClientScript.RegisterClientScriptInclude(this.GetType(), "MyControl",RichText); 

i registered javascript files in AssemblyInfo.cs like this :

[assembly: WebResource("MyControl.js.RichText.js", "text/javascript")]
[assembly: WebResource("MyControl.js.testJS.js", "text/javascript")]

Gzip compress pages


Hi All

How to compress the pages by gzip under MVC?

Any best practice?

Thanks and Regards


cache javascript files


I've been trying to find a good example of exactly what I need to do to cache for some timeframe a set of javascript links.

For example in the masterpage I have the following script which I can't imagine changing for quite some time (say 6 months)

<script src="JavaScript/ImageLoading.js" type="text/javascript"></script>

Would be great if I could work out where and what to put to cache this for 6 months.

Accessing External Javascript files (.js) in VWD 2010 (.Net 4)


Hopefully I've selected the appropriate forum to post. If not, kindly let me know and I will post in that forum.

I have searched hundreds of posts over countless forums, but am unable to run a Javascript that is placed in a separate .js file. If the script is placed directly in the <HTML> and ASP markup, the script runs fine. I am a newbie at this and resolution may be quite simple. But I cannot figure it out.

I have simplied the example down to a single .aspx page with a single button and the codebehind in VB, knowing that if I cannot get this working, I certainly won't be able to get my real scripts working.

I am currently running VWD 2010 on the .Net 4 framework. I've been working on this problem on and off over the past 3 weeks and simply cannot get it to work, so I continue to insert the code directly into the markup. I have tried countless changes to the following code, but not once able to get it to work.

Any help, suggestions or recommendations will be graciously accepted and very much appreciated.


The .aspx page is as follows:


<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Test_Script.aspx.vb" Inherits="Test_Script" %>



Export to Excel big size files (10000 pages) - HTTP Error 401.1



If you attempt to export a file to Excel, the browser hangs for a long time, then begins to request authorization, several times in succession .
Then displays an error message: "you are not authorized to view this page"

Need to mass load dated files from .txt to sql table - what is the best way?



I have around 500 files which are named file_27072009.txt, file_28072009.txt, file_28072009.txt etc and I need to load them all into a table. What is the easiest way to pick up each of these files in turn and load them into the sql table?

I have access to SISS or sql server mgt studio but am not an expert in either.

Any help would be much appreciated so I am not having to manually open and merge all the files into one before loading.

Thanks so much


ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend