On the do last night, we were discussing some issues that crop up in Gmail, including how it relates to some messages from AC, in particular, booking confirmations from Aeroplan (titled "SCOTT , your Aeroplan Flight Reward confirmation").
If you have more than just a few segments, you end up with an email truncated at the end:
The clipping happens if an email body exceeds 102 KB, based on various unofficial online references.
The email in question here is 151 KB, which is why it was clipped.
I took a look at the body, and it's a bunch of formatted HTML.
When I say formatted, what I mean is it looks like this:
Code:
<td width="279" valign="top">
<table cellpadding="0" cellspacing="0" border="0" width="100%">
<tr>
<td width="20" valign="top">
</td>
</tr>
</table>
</td>
The above is 202 characters. The email was encoded in UTF-8, so that also means it's 202 bytes.
In HTML, 2 spaces are equivalent to 1 space everywhere. In most cases, you don't even need spaces, but a very simple optimization would be to remove duplicate whitespace characters, so it looks like this:
Code:
<td width="279" valign="top"> <table cellpadding="0" cellspacing="0" border="0" width="100%"> <tr> <td width="20" valign="top"> </td> </tr> </table> </td>
That brings it down to 154 bytes, a 24% reduction. As an aside, FT keeps trying to strip the extra spaces in the first block, so I had to be careful when I finally submitted this post to ensure they showed up.
However, in the real email, each of those lines was actually indented with an additional 72 spaces. That means the original section was actually 778 bytes, and the shrunken version would still be 154, which is actually an 80% reduction in size.
If we perform this simple replacement (i.e. replace("\s+", " ")), the 151 KB becomes 67 KB. That's a 56% decrease in message body size. Aside from the general benefits of saving time (for AC's servers and our own browser loading) and money (it costs money to transmit data), this also means it's now below Gmail's clipping limit, and can be displayed in its entirety, which I was easily able to test. Now I can see the entire itinerary, cost, tax breakdown, disclaimers, etc., without having to click to open a new tab.
However, that was a naive solution. For example, "</td> </tr> </table> </td>" can just as easily be "</td></tr></table></td>". Those spaces were unnecessary. There are also HTML comments, which are completely unnecessary here. Comments are useful for developers looking at code, but they serve no practical purpose to the end user looking at the rendered result.
Using a proper HTML minifier, which removes all unnecessary whitespace, comments, etc., we get it down to 59 KB, or a 61% reduction.