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!!!

html-email-minified-code-inline

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!

Author
Gergely Mecs

Gergely Mecs

Chief Frontend Developer @ EDMdesigner.com

  • HTML Email Development Tools HTML Email Development Tools

    Would you like to improve your HTML email development workflow and learn about new developer tools? This article series is for you.

    Read more
  • Git Branching Workflows in SaaS Development and the Review ASAP Policy Git Branching Workflows in SaaS Development and the Review ASAP Policy

    This article shows you a git branching workflow which helps developers to review changes frequently, leading to better code quality.

    Read more
  • Tabular Data Representation in Modern HTML Emails Tabular Data Representation in Modern HTML Emails

    Responsive tables are the most common ways to represent tabular data in HTML emails. Learn about the best practices and the card layout design approach.

    Read more