You may have heard of JavaScript. In case you haven’t, you should know that JS is one of the most popular programming languages in the world. It is also the tool can take your website game to the next level, especially if you are interested in giving your brand a modern edge. JavaScript can accomplish such by adding interactivity and animations, or by generating dynamic content in your site. Not only does JS turn sites into complex software applications but it can go beyond the web, to servers and embedded hardware controls.

After reading about all those marvellous features and seeing how it can help your website, you may be thinking of using some awesome JavaScript functions in your email templates. If it was me, I would have already gone and gotten me some of that JavaScript!

Unfortunately, this is one of those situations where what’s good for the goose is definitely not good for the gander! 🙁

JavaScript in Email Templates is an absolute NO!

Although JavaScript is responsible for making web content fun and interactive, email clients are not very fond of it. Scripts are blocked by nearly all major email clients, as support is either extremely limited, or nonexistent.

Webmail clients, most of which use JS to run their interface, are not crazy about the idea of having JavaScript in email templates potentially causing them an error of some type. Unfortunately, hackers and people looking to steal information also sometimes use JS in emails. Running JavaScript in email templates can create serious security threats. Hence why it makes sense to have email clients blocking them by default. Scripts can hide malicious content and, thus, it makes sense to block them. Think of the obvious security risks that could arise from having a malicious script running inside an application (AHEM your email), which contains all your personal information! To prevent a catastrophe, most email clients strip out or disable JavaScript to avoid malicious code execution and other security risks.

Even in the cases where JavaScript might run, the benefit of using it in email templates is not worth the risk of having your email end up in the spam folder. Even if a spam filter allows your email to get through, most email clients will not allow scripts to function. This happens because, for an email’s HTML to render properly, it first needs to pass through a preprocessor. The job of a preprocessor is to remove anything that could be potentially dangerous and introduce privacy concerns. It could even cause the email to behave unexpectedly, which is not worth the risk.

Then how do I make my content more engaging?

Keep your email templates as straight HTML and CSS, and avoid the hassle. You may think that there is no fun in doing that but you will be surprised about the power of CSS and what some thinking outside the box can do. Here is an example of what I mean by that. UK Retailer B&Q went ahead and created spectacular campaigns and had no need to use JavaScript in email templates. Check out the template, which got a lot of attention for an email template:

JavaScript in Email Templates - This example does not use JS

Image from Litmus’ This is The Future of Email Design. Believe it or not, there is not JavaScript behind it. Just pure CSS hovering and z-index items. Cool, eh?

Another option to make your email template more interesting is to try and use gif images. Do know that they are not supported by all email clients. This means that the image will only show the first frame in those clients that do not support gif format. Those that do, however, will enable you to feature fun images like this:

JavaScript in email templates: Peanut butter jelly time

Peanut butter Jelly time Yeah!

Have any further questions about JavaScript in Email templates? Contact us today!