I suggest you ...

Compress and minify published ASP.NET pages

I made a small test and on a standard ASP.NET page, just only with removing whitespaces and line breaks, page size decreased by %35-40. Lower page size means higher performance. There are solutions for it but all are based on server side dynamic solutions. But there is a simplier way. For ex. just clean it when it is published and generate dynamic controls accordingly. It won't any give runtime overhead and will only give performance.

448 votes
Vote
Sign in
Check!
(thinking…)
Reset
or sign in with
  • facebook
  • google
    Password icon
    I agree to the terms of service
    Signed in as (Sign out)
    You have left! (?) (thinking…)
    Ömer ÇelikÖmer Çelik shared this idea  ·   ·  Flag idea as inappropriate…  ·  Admin →

    12 comments

    Sign in
    Check!
    (thinking…)
    Reset
    or sign in with
    • facebook
    • google
      Password icon
      I agree to the terms of service
      Signed in as (Sign out)
      Submitting...
      • Ömer ÇelikÖmer Çelik commented  ·   ·  Flag as inappropriate

        As I mentioned before also, there are of course dynamic solutions which needs extra runtime overhead, but it is a simple operation which doesn't need to be during runtime but only during publishing. Sorry to hear that it is declined. As Microsoft, you should support developers to minify all resources to make web even faster.

        Now, Post-Build or After Publish events can be used on MVC projects for minification but for classic ASP.NET projects controls needed to be overridden to generate proper output or runtime solutions can be used.

      • Anthony Brian WallAnthony Brian Wall commented  ·   ·  Flag as inappropriate

        This was probably declined because we should all be writing "ubobtrusive" HTML which means just the content, ids and class names needed to add the layout and styles "unobtrusively", i.e. everything else dealt with in external JavaScript and CSS files (most likely applied via Bootstrap and jQuery). ASP.NET already supports automatic minification of these files via the "bundles" feature, leaving only the HTML of which only white space is safe to auto-remove. So that means no point trying then for Microsoft.

      • Scott GallowayScott Galloway commented  ·   ·  Flag as inappropriate

        Not sure about this, HTML minification even at best offers really minimal benefit when you also apply HTTP compression; however the potential for poor rendering in browsers is huge.

      • Ömer ÇelikÖmer Çelik commented  ·   ·  Flag as inappropriate

        GZip is different technology to minify and it can be used with my idea also. I mean minification of HTML output (views for ex.) during publishing phase (or for web controls generate minified output). It won't give any runtime overhead. It will be like minified versions of JavaScript files, you can still use GZip but it is minified by default.

      • Inderjeet WadhwaInderjeet Wadhwa commented  ·   ·  Flag as inappropriate

        Luis -- Gzip is data compression technique which needs to be uncompressed before rendering by browser so we will not get performance benefits sometime .

      • Inderjeet WadhwaInderjeet Wadhwa commented  ·   ·  Flag as inappropriate

        This is read good idea. It was always uneasy to minimize each file before publishing or on run time. Doing it on run time decrease performance and minimizing files manually make it less manageable code.

      • LuísLuís commented  ·   ·  Flag as inappropriate

        No need for that. You should just gzip your page and you're done. Well... You should be doing this already...

      • Bertrand Le RoyBertrand Le Roy commented  ·   ·  Flag as inappropriate

        Almost all controls use a html text writer. It should not be too hard to pick at runtime between the regular one used today and a compressing one, based on config.
        What will be more of a challenge, however, is the static strings in aspx and cshtml files. You would need a different method for those. One possibility would be to do the compression at compile-time, based on the debug/release current config. When compiling a file, the generated code could feed compressed strings to the compiler.

      • AnonymousAnonymous commented  ·   ·  Flag as inappropriate

        What is URL REDIRECTION?How can i use this concept in my .net?
        my task is i have generated one url like this "http://example.com/";
        I am passing one pearameter like "http://example.com/Empno=1";
        I want to display Ename in Database table that corresponding "Empno"
        plz Help me Give me one simple example

        I am new this concepts
        plz Help me send source code to my mailID:mandla.anilbabu@gmail.com

      • Ömer ÇelikÖmer Çelik commented  ·   ·  Flag as inappropriate

        It is good, but my point is doing this on dynamic pages without any effort. So, when debugging etc. it will show full page output with indentation etc. But when it is published, it means it is ready to be deployed, clean the HTML tags and publish accordingly. So, no runtime performance decrease and we will get smaller pages.

      Feedback and Knowledge Base