javascriptjqueryseogoogle-searchobscured-view

Hide links from Google via JavaScript


We have some links we want to hide from Google, using Javascript to "hide" the link but let it work for the real clients.

I was told from the SEO agency that the best method is to base64 encode the link and call it via javascript:

<a data-href="RdcDovL1N0YWdpbmc...base64...hhcmRpbmctaGVycmVuLWhlbaQtMTgyMDg3"
   href="#">Link</a>


<script>
<!--
var _dlist = document.getElementsByTagName('A');
for(i=0;i<_dlist.length;i++) {
    var _data = _dlist[i].getAttribute( 'data-href' );
    if( _data !== 'null' ) {
        var _extend = CryptoJS.enc.Base64.parse( _data );
        _dlist[i].setAttribute( 'href', _extend.toString( CryptoJS.enc.Latin1 ) );
    }
}
-->
</script> 

My problem now is, I don't want to include another 2 files (they suggested me crypto-js lib) just for the links. I'd like to ask you, how far does Google reveal links and follow them and what's the easiest approach without loading more scripts. jQuery is available.


Solution

  • This is what I ended up with:

    Links look like:

    <a href="#" onclick="linkAction(this); return false;" 
       data-href="uggc://fgntvat.....">
    

    Where data-href is Rot13 encoded and linkAction does:

    function linkAction(e) {
        window.location = rot13($(e).data('href'));
    }
    

    ..in an external JS file.

    I think this is the best obfuscation without performance overhead. Let's see what the SEO agency says :-)

    P.S Rot13 taken from: Where is my one-line implementation of rot13 in JavaScript going wrong?