Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to optimize repeater white-spaces

In my repeater I have the following markup:

    <asp:Repeater runat="server" id="TeamsRepeater" OnItemDataBound="TeamsRepeater_ItemDataBound" ClientIDMode="Predictable">
        <ItemTemplate>
            <tr runat="server" id="team">
                <td><%# Container.ItemIndex + 1 %></td>
                <td><%#Eval("PosChange")%></td>
                <th><%# ((ITeam)Eval("MemberTeam")).Href()%></th>
                <td><%#Eval("GamesAll")%></td>
                <td><%#Eval("GameW")%></td>
                <td><%#Eval("GameD")%></td>
                <td><%#Eval("GameL")%></td>
                <td><%#((ITournMember)Container.DataItem).Goals()%></td>
                <td><%#Eval("Score")%></td>
            </tr>
        </ItemTemplate>
    </asp:Repeater>

That is pretty readable (and maintainable, please point me if you see something can be done better).

But my concern is that HTML code generated for this markup contains a huge amount of spaces...

How could I enhance that in order:

  1. remove unnecessary spaces from output html;
  2. in the same time: keep markup readability?
like image 841
Budda Avatar asked Feb 24 '23 08:02

Budda


2 Answers

You could try this HttpModule that removes whitespace.

like image 78
alun Avatar answered Feb 25 '23 21:02

alun


I wouldn't sacrifice readability to get rid of spaces. This will hurt you in the long run. Instead enable compression for your dynamic content, i.e. with IIS HTTP Compression - the end result will be dynamic gzip compression on your aspx pages that are much smaller than your plain HTML.

like image 21
BrokenGlass Avatar answered Feb 25 '23 22:02

BrokenGlass