{"id":11687,"date":"2012-02-24T18:38:11","date_gmt":"2012-02-24T17:38:11","guid":{"rendered":"https:\/\/www.saasweb.agency\/blog\/protecting-email-addresses-from-scrapers-with-javascript-or-jquery\/"},"modified":"2026-10-27T08:32:35","modified_gmt":"2026-10-27T07:32:35","slug":"protecting-email-addresses-from-scrapers-with-javascript-or-jquery","status":"publish","type":"post","link":"https:\/\/www.saasweb.agency\/en\/blog\/protecting-email-addresses-from-scrapers-with-javascript-or-jquery\/","title":{"rendered":"Protecting Email Addresses from Scrapers with JavaScript or jQuery"},"content":{"rendered":"<p>If you publish your email address or those of others simply as HTML code, there is a risk that the addresses will be read automatically by scripts for the purpose of using them as recipients for spam. There are several more or less effective ways to make the addresses visible to website visitors while making automated reading more difficult. <\/p>\n<p>One of these methods is to clear the address of unique features such as <strong>@<\/strong> (as every email address is known to have exactly one @) or <strong>.<\/strong> (as a separator between the domain and TLD) by replacing these characters with markers and then swapping them with the correct characters at runtime.<\/p>\n<div>So, instead of writing in the HTML source code\n<\/div>\n<div class=\"code-snippet\" style=\"margin-top: 5px; margin-bottom: 15px;\">&lt;a href=&#8221;mailto:mailname@domain.tld&#8221;&gt;mailname@domain.tld&lt;\/a&gt;<\/div>\n<div>\nwe write\n<\/div>\n<div class=\"code-snippet\" style=\"margin-top: 5px; margin-bottom: 15px;\">&lt;span class=&#8221;amailto&#8221;&gt;mailname at domain dot tld&lt;\/span&gt;<\/div>\n<div>\nJavaScript (jQuery):\n<\/div>\n<div class=\"code-snippet\" style=\"margin-top: 5px; margin-bottom: 15px;\">\n$(document).ready(function(){<br \/>\n&nbsp;&nbsp;var at = \/ at \/;<br \/>\n&nbsp;&nbsp;var dot = \/ dot \/g;<br \/>\n&nbsp;&nbsp;$(&#8220;span.amailto&#8221;).each(function(){<br \/>\n&nbsp;&nbsp;&nbsp;&nbsp;var addr = $(this).text().replace(at,&#8221;@&#8221;).replace(dot,&#8221;.&#8221;);<br \/>\n&nbsp;&nbsp;&nbsp;&nbsp;$(this).after(&#8220;<a href=\"mailto:\"+addr+\"\" title=\"Send email\">&#8220;+ addr +&#8221;<\/a>&#8220;);<br \/>\n&nbsp;&nbsp;&nbsp;&nbsp;$(this).remove();<br \/>\n&nbsp;&nbsp;});<br \/>\n});\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>If you publish your email address or those of others simply as HTML code, there is a risk that the addresses will be read automatically by scripts for the purpose of using them as recipients for spam. There are several more or less effective ways to make the addresses visible to website visitors while making \u2026<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[981,983],"tags":[984,997,2073,866,837],"class_list":["post-11687","post","type-post","status-publish","format-standard","hentry","category-programming","category-tutorial","tag-email","tag-javascript","tag-jquery","tag-spam","tag-spam-protection"],"acf":[],"_links":{"self":[{"href":"https:\/\/www.saasweb.agency\/en\/wp-json\/wp\/v2\/posts\/11687","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.saasweb.agency\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.saasweb.agency\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.saasweb.agency\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.saasweb.agency\/en\/wp-json\/wp\/v2\/comments?post=11687"}],"version-history":[{"count":0,"href":"https:\/\/www.saasweb.agency\/en\/wp-json\/wp\/v2\/posts\/11687\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.saasweb.agency\/en\/wp-json\/wp\/v2\/media?parent=11687"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.saasweb.agency\/en\/wp-json\/wp\/v2\/categories?post=11687"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.saasweb.agency\/en\/wp-json\/wp\/v2\/tags?post=11687"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}