I have a pretty big web site (asp.net web) and I have used JavaScript intensively (jquery,custom javascipt, etc) and also The theme and CSS. Right now I have a huge amount of js and css files in my system and I am thinking about minifying and smashing the js and css to improve the performance. So, please advice me the suitable tools and technologies to be used and please suggest me the best practices to be applied in these scenario.
There are a couple of things you could try to improve performance.
Enable GZIP
Enable 'Retail' attribute in machine.config
Enable Page Caching
I've listed the techniques we have used at our organisation to improve the performance of our web applications. With the exception of GZIP the other two probably won't have a direct effect on the JS and CSS files but will save you valuable loading time in other areas making your web site much faster.
We always see huge increases in speed and performance when the retail attribute is set to 'True' - all forms of debugging are disabled in this mode which makes the site more responsive.
Obviously you only want this setting on your live server.
If you're using jQuery, you should already be using the minified version on your production site.
For your own Javascript, there's Douglas Crockford's original minifier, or you could use the Microsoft Ajax Minifier, which you can add as an MSBuild task - there's an overview here.
There's a number of CSS minifiers referenced in the answers to this SO question.
Best practices are great but, at least in the case of performance, the question is more about the right practice. The only way to know is to:
Measure
Try
Measure Again
Compare/Contrast
It is almost always a trade-off with optimizing software. You have to consider how a change effects readability, scalability, security, deployment complexity, and probably a lot of other ity's I am not thinking of.
Having said all that the practices you are looking for are pretty much here.
To make my point though consider the rule Use a CDN. This seems like an obvious choice for something universal like jquery. You can use both MSFT and Google for this. You have the potential advantage of parallel download (depending up on the client browser) and the added possibility of already being in the client cache (from other site they may have visited). Plus they are likely serving it closer to the user than you are.
But the trade off to consider is that it is going to eat some bandwidth so if you are building something that is sitting in the Intranet, don't do this. You also introduce the possibility of failure from an external source. You can work around that by adding more code.
Perhaps most importantly though is that using a CDN is in direct contrast to the first rule, reduce HTTP requests. If you can combine and minimize all your js and load it more efficiently locally then you should do so. How do you know?
You have to:
Measure
Try
Measure Again
Compare/Contrast
Have fun!
Related
My last project is a medium size asp.net web forms application. It is built using:
asp.net 3.5
ling to sql dbml --> sql server database (9 tables)
ext.net 1.6 (www.ext.net)
structuremap 2.5.3.0
This time I believed I did my best in terms of architectural design, code and data transfer optimizations. I followed all advice I could to work with the database efficiently through linq to sql and I built layers (model, repository, service, presentation) to separate concerns and lightweight the code in the aspx code behind files.
The problem is: I've installed the application in various web hosting servers with the same pitiful result: the application is struggling to work... pages are loading like in slow motion...
In the past I would say 'OK, I didn't do all I could to speed things up' but in this case I really tried to apply the best practices...
Is there anything else I can do about it? Or is it just asp.net for really small projects only?
thank you.
ASP.NET is fine for building large scale websites. As Brad mentioned, StackExchange sites are built using it, and StackOverflow is a very busy site indeed.
What you need to do first is measure performance; until you do that, you're just guessing at where the problem areas are.
So start with the browser - use a tool such as Firebug, or YSLOW, Google Chrome dev tools, whatever takes your fancy and run your site using the tool enabled. The tools can let you know how long things are taking to process eg requests, how long content is taking to download etc.
YSLOW will also give you some tips on anything it finds as being a bit slow e.g. you're making to many HTTP requests, you should consider minifying your CSS/JS files. You will get a general overview of how the site is performing and where problems could be.
To dig a bit deeper, use a tool like RedGate's ANTS Profiler, use the trial version and measure your website, and server side code, with that tool. There are other tools, though I'm not aware of any free ones.
My first question is that when its slow. Did you try your project in Local area network. Please check first there. If there slow then you need to improve little bit.
This slow performance depends on many things
such as large data load, multiple logic on one page etc.
Please let me know.
Thanks
Basit.
When designing a ASP.net WebForm application what are some important steps to take (or hacks if you like to use the term) to ensure the best possible performance (in terms of speed, stability, and scalability)?
Avoid round trips to server
Wherever possible user AJAX calls.
Implement Caching.
Avoid using Viewstate wherever possible
For further more read these links.
Improve Web Application Performance
ASP.NET Web Site Performance Improvement
Since so many things can affect performance, it's difficult to provide such a list. We may make assumptions about your code that aren't correct, and may focus on the wrong areas while you suffer poor performance from something we would otherwise take for granted.
Having said that, in general you might keep an eye on:
Don't over-use ViewState. (I'd argue not to use it at all, but that's another issue entirely.)
Keep page resources small (minified text, good image encoding, etc.).
Ensure page resources are properly cached once downloaded.
Try to move most UX logic client-side. (Avoid post-backs for things you can otherwise do in JavaScript, fetch data asynchronously where possible in small chunks, etc.)
The list can go on and on, and that's just with the web tier of the application. You could easily encounter site performance problems resulting from slow server-side code or server-side resource dependencies (database, etc.) that can't be debugged in the browser.
So the main point is to learn your debugging tools. Through combinations of browser tools (FireBug, Chrome Developer tools, etc.), Visual Studio debugging (or whatever else you may use for your .NET code), good logging, and even profiling tools you can identify your bottlenecks and tweak your system accordingly.
Check your website in google page speed :click
It will give your problem . for unwanted style.images and etc.......
If you care so much for speed, stability and scalability you might first question whether ASP itself is a good compromise
when it comes to performance of the web application we need to consider many things this article will help you understand what performance is where to start.
In web application 80 percent of the time it is front end which requires performance optimization, what needed to be optimized is a big question and really hard to answer
this article i found will help you understand the web performance optimization
Web Performance Optimization
Can any help regarding the performance improvement in Asp.Net?The best practise tips for asp.net performance improvement?
This is a very broad question to answer because the Performance of an ASP.Net application is not only bound to page processing or bandwidth usage but also in the code and Algorithms you have written. If you use data source then the Performance of the Queries and ADo.Net. The Basic thing you might be asking is to improve page processing by Caching, etc..
Have a look here for a detailed description of Best Patterns and Practice (Though its old ..published in 2004 but still helps).
http://msdn.microsoft.com/en-us/library/ff647215.aspx
Or better consider this (For .Net4) . It list all performance related Documentation
http://msdn.microsoft.com/en-us/library/cc668225.aspx
Update
If you are looking for specific stuff slowing your page load
Use firebug's Net panel and monitor which resource is taking more time. Or as suggested by another answer use Tracing to check this out.
What is the best drug to get healthier? It all depends on what is your health problem. The same thing is with ASP.NET performance. First, find what is your bottleneck, a single most slow down factor. Then fix it, retest performance and, if more speed is necessary, go to the previous step.
How to find a bottleneck? If you really have no clue where to start, then start from analyzing your waterfall diagram. To create one from your client, use Fiddler or Firebug. To create it from different Internet geographies use WebPagetest. The waterfall will show whether the bottleneck is on the server or network, and also whether it is caused by main ASPX page or by resources (scripts, images, CSS). If the server and network are fast enough, then check slowness in the browser using Firebug or dynaTrace Ajax edition that can trace DOMContentLoaded/load events in browser. If the bottleneck is on the server, find out whether it is the database or application. Use database profiler and .NET profiler, for example from this question.
How to fix bottlenecks? Check this Microsoft resource, but there are many others for each type of bottlenecks.
If you add the “performance“ tag to your question you may get more answers.
Set trace="true" in the page directive. Reload the page and look for any obvious delays in the page life-cycle event handlers, particularly where you are accessing a database.
Also, use the Firefox Web Developer toolbar to obtain a friendly overview of the image file sizes and other static file sizes, CSS, JS, etc.
There are lots of questions and answers on ASP.NET performance here on Stackoverflow. Here's one of my previous answers and a quick search on the ASP.NET and Performance tags yields plenty of results.
What problems are you facing exactly?
I ve developed an asp.net web application with YUI as the javascript library... My site was very slow that it took three minutes to view my page on my first visit....
When inspected through firebug, My yui file was too heavy with size
278kb...
what can be done to improve performance?
278k is less than many images that appear on websites, and YUI is only as heavy as the component stack that you have requested. The common core package yahoo-dom-event.js is 37k (12k gzipped), so you are requesting at least a few other modules. That said, even across a slow connection, 278k should not cause a 3 minute delay. I suspect there is something else causing the performance issue.
There are many tactics for improving page performance. As MontyBongo suggests, use the Yahoo! CDN. If you are hosting the files yourself, make sure you have gzip enabled on your server. One benefit to using the CDN is the ability to use the Combo handler, which bundles all modules into a single script file. If self hosted, you should look into creating manual rollups of the files you are using to emulate this. Also, look into the YUI Loader to bring in module files asynchronously. http://developer.yahoo.com/yui/yuiloader/
Otherwise, look at http://developer.yahoo.com/performance/ and ask on yuilibrary.com/forum for advice. Please note that you should always supply some code for reference when asking for advice to improve it. Paste code snippets inline, link to larger snippets on http://pastie.org or http://gist.github.com, link to the page in question, or (best of all) link to a reduced page that illustrates in isolation the issue you want to address.
Try compressing the javascript with gzip, if possible use the Yahoo or Google CDN to deliver the files:
http://developer.yahoo.com/yui/articles/hosting/
Also try install YSlow, it can give you some good feedback on whats causing your page to load slowly, and provides some tips on optimizing the javascript delivery
http://developer.yahoo.com/yslow/
I agree that YUI is a bit too heavy for many sites.
In case it helps, you might want to have a look at my book for some ideas on how to make things run faster: Ultra-Fast ASP.NET: Build Ultra-Fast and Ultra-Scalable web sites using ASP.NET and SQL Server.
Obviously having whitespace in css, aspx and html pages is a great advantage at design time. But is there a way to (a tool that will) clear all the whitespace from all the files and possibly merge javascript and css files in a more optimal way.
I am using asp.net themes so there are quite a lot of separate css files that would be improved through some form of automated combining. I have seen a few http modules but that isn't quite what I want I just want to run something over the published project beofre sending it to the server.
EDIT: Compression at least in IIS is unfortunately not an option, we are currently running it on the same IIS server as a third party web based student management system. It doesn't like compression and the IIS options don't seem to be per application pool. I did apply asp.net compression but the bulk of my extra data seems to be the app_themes which I know would compress well I just don't want to have to manually go through compressing all the css separately.
An empirical study on the effect of removing white space from a not-untypical website (Drupal) showed minimal effects. (site also contains some links to non .net html white space removal tools)
I have gotten magical improvements in page size by aggressively managing viewstate size and using Blowery's http compression module.
Another strategy is to do minifiation (merging many css files into one). Telerik has such a component RadStyleSheetManager, it works only with style sheets embedded into assemblies.
There is another way
http://omari-o.blogspot.com/2009/09/aspnet-white-space-cleaning-with-no.html
I think one of the reasons that this was never included in .NET was because they expected you to turn on server compression in these scenarios. IMO I don't agree with this -- I think it's a shame that at least aspnet_compiler.exe can't do this optimization. It would be such a great performance boost on uncompressed connections. Anyway, you can enable compression on IIS 6:
http://www.microsoft.com/technet/prodtechnol/WindowsServer2003/Library/IIS/d52ff289-94d3-4085-bc4e-24eb4f312e0e.mspx?mfr=true
And it's even easier and more flexible in IIS7 to do so. I hope someone has a better solution than I!
4 guys from Rolla just published an article on a http module that removes white space. You would need IIS 7 in integrated mode to make it work for css (or possibly IIS6 with wildcard mappings)
It looks more like a proof of concept, but the code is free.
i found this:
http://msdn.microsoft.com/en-us/library/aa719805(VS.71).aspx
greets!