0

Many times when I view source my page.aspx, I find lots of lines (HTML, styles, java script, view states, etc) maybe thousands of lines. On the other side when I view the source of more complicated pages of others' sites like (SOF), I find small numbers of lines typically XHTML

  • Does this mean my pages are less performance and not that valid?

  • What is the reason ? some bad practices i made when i build my pages or as a result of the bad rendering of web forms aspx?

  • Should I turn to asp.net-MVC instead?

Andrew Barber
  • 39,603
  • 20
  • 94
  • 123
Anyname Donotcare
  • 11,113
  • 66
  • 219
  • 392
  • 1
    This (unfortunately) titled SO question should shed some light on things for you: http://stackoverflow.com/questions/46031/why-does-the-asp-net-web-forms-model-suck – NakedBrunch Dec 13 '11 at 23:17

1 Answers1

2

Well, it depends...

smaller pages load faster. Full stop. For sure a large page will take longer to load so that is not good for you. Also your text to html ratio can influence your seo result.

looking at the different items:

Styles: they should be in separate css files. Gives you better caching and reuse. Has nothing to do with mvc or not. Use the cssfriendly controls for asp.net.

Javascript: same here, use a CDN for stuff like jquery, ajax.net etc. and put your own scripts in one, minimized separate .js file. Not in your page.

viewstate: yes, this can kill performance and it grows fast. Especially on gridviews. You do not always need it and it can be turned off. Use with care... There is a lot to gain here.

Naming of your repeaters, content placeholders etc come back lots of times so keep them small in terms of nr of characters. Will also give you some help.

If you follow this, what is left is your html and the necessary viewstate. if done well there is not always a need for MVC. The size difference will not be that big anymore. Mvc gives you more control and It has other advantages though but the size of your page it should not be your primary motivation. Asp.net 4.5 will add compression and minification so it will be even less important. But the bottom line is that with large volumes every byte counts...

Pleun
  • 8,856
  • 2
  • 30
  • 50
  • 1
    An interesting discussion whether to keep all the JavaScript logic in one or multiple files: http://stackoverflow.com/q/8410298/583539 – moey Dec 14 '11 at 00:03
  • 1
    @Siku-Siku.Com Interesting. if you have a couple of large scripts that are being used in only a couple of your pages you can split up of course but OP seems to have inline scripts... – Pleun Dec 14 '11 at 00:06