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

  • 16 Command Examples to Send Email From The Linux Command Line 16 Command Examples to Send Email From The Linux Command Line

    In this post you'll learn how to send emails from the Linux command line. I'll show the most often used commands, SMTP configuration and terminal options.

    Read more
  • How to Create Responsive Email Designs with React Native How to Create Responsive Email Designs with React Native

    Responsive email coding is complex. Are you native in React Native? Abstract away email HTML & CSS into components with react-html-email or mjml frameworks.

    Read more
  • Using PHP for Sending HTML Emails with Mailgun, Sendgrid & Amazon SES Using PHP for Sending HTML Emails with Mailgun, Sendgrid & Amazon SES

    Ever wondered how to use PHP for sending HTML email templates with Mailgun, Sendgrid and Amazon SES? Read on for step-by-step coding advice.

    Read more