1

We are in a urgency to implement fileaggregation for Javascript and css files

We hav 12 javascript files and 8 css files.

There are lot of experienced people , can you please suggest which tool should i use to compress them into one js and css file.

If i compress them , how can i change in the code , right now they are inserted in the msater page. All css and js files are included in the master file of the website.

Thanks in advance.

2 Answers 2

2

Based on the fact that you mentioned master page, I assume that you are working with ASP.NET. In that case, there's a built-in tool to do that. You can use and in order to notify ASP.NET engine that you want to combine javascript files. It will take care of the rest for you. This is for ASP.NET 3.0 or above, or ASP.NET 2.0 with MSAJAX installed. Here's an example of how to use it:

<asp:ScriptManager runat="server"> 
 <Scripts> 
  <CompositeScript> 
   <Scripts> 
    <asp:ScriptReference Name="MicrosoftAjax.js"/> 
    <asp:ScriptReference Name="Custom.Extender.1.js" Assembly="Custom" /> 
    <asp:ScriptReference Path="~/Scripts/Custom2.js" /> 
    <asp:ScriptReference Name="Custom.Extender.2.js" />
   </Scripts> 
  </CompositeScript> 
 </Scripts> 
</asp: ScriptManager> 

For more information, see this link: ScriptManager

Sign up to request clarification or add additional context in comments.

2 Comments

@this website simply rocks...thanks everyone , i am marking yours as answer.
Keep in mind that ScriptManager is just for a quick and dirty job. It will combine all your files into one, will not really let you set up caching to the way you want and it's going to be very tough to set it up for CDN. For something more robust you will probably need to write your own solution. It's not as hard as it sounds. And gives you full control.
2

Yahoo's YUI compressor: here for javascript. But I am not 100% sure if you can simply merge all the javascript files into one, because I suspect that would be depending on the way how people program in those scripts.

And here is CSS compressor, you can always use tools like Firebug to detect unused CSS rules so to remove duplicated/unnecessary CSS rules.

I highly recommend Google's Page Speed as an add-on for Firefox, this would reveal the "bottleneck" of your website's performance.

1 Comment

Yeah based on Yslow and pagespeeds suggestions, i want to implement this.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.