Ros at Campaignmonitor’s blog mentioned the idea to minify your HTML to speed up the sending process. At first sight it seems to be a good idea, because the minified output will be much smaller without any unnecessary spaces, tabs, and line-breaks. A good HTML tidy solution will validate your code and reduce the size of your final HTML by stripping HTML comments and other “unnecessary” things from your email too.
But wait a minute!
So we will strip out all unnecessary spaces, tabs, and line-breaks which are covered by the HTML standards… but in email there are NO real standards!!!
Step one back, and think through what will happen with your HTML code. After the minifier removes all nonessential line breaks, the HTML will be in one “never-ending” line. Most email software have many inbuilt limitations. One of the trickiest limitations that exist in the Email Universe is the line length.
Modern HTML parsers can handle minified HTML and CSS as well, but Outlook won’t! Since old IE and MS Word engines, which are the basis of Outlooks, have problems with understanding long lines. Even the modern, Firefox based Thunderbird will break on the hard line break. These kind of breaks will have a really bad impact on your email designs and may ruin the whole layout of your email in some cases.
The line length limit is usually 998 characters plus CR and LF characters per line (for more: RFC5322). The same limitations exist in a lot server-side spam filter solutions too, so it is not so wise to remove all line breaks from your email HTML!
Is it safe to remove spaces and tabs?
Its a little bit harder to give a correct answer, but we’ll list he most common issues, so you can decide:
- Some email clients may behave in a very strange way when you remove the tabs or spaces in front of the CSS selector in the HEAD of your HTML.
- Some other desktop clients ignore CSS definitions without spaces on inline HTML style attribute. For example we discovered through heavy research, that Gmail ignores the background image of the email body, if we use the proper and valid CSS background property. But if you put one more space in the right place… It works!
- There is a strange DOCTYPE and charset related issue, which causes problems in some cases.
- Some of email clients only apply one CSS property:value combination per line in the HEAD style tag.
Minify is only a good idea if you can keep the line lengths, and all CSS related things untouched! In this case it’s a very good improvement that will definitely speed up your sending process, but DO NOT FORGET to TEST and be careful!
Background Images in Modern HTML Emails
This article uncovers the approaches how background images can be set in email HTML. Various emailRead more
Bulletproof HTML Email Buttons - A New Line-height Based Approach
In this article I am going to put to the test the basic bulletproof button techniques,Read more
Content Images in Modern HTML Emails
In the last few months I have been following the previous posts of the Modern HTMLRead more