Take the 2-minute tour ×
Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

It's a fairly common practice for webmasters to rel=nofollow external links, and I frequently see it done with jQuery. The script typically looks something like this (off the cuff here):

jQuery(function($) {
    $('a[href^="http://"]').not('a[href*=mydomain]').attr({
        'target'    : '_blank',
        'rel'       : 'nofollow'
    });
});

Essentially jQuery crawls the DOM, finds every link with an HREF, and if it's not part of "mydomain" appends target="_blank" and rel="nofollow" - works a treat, right?

There's just one problem.

It is my understanding that Google and other search engines read the original source and generally ignore the JavaScript, except to penalize Spam tactics or attempt to decipher some limited AJAX.

So I've got to ask - this is a neat little script, but does it even work? If not, then I should go back and execute this sort of thing in PHP before the page is rendered.

Thanks in advance for sharing your knowledge.

share|improve this question

1 Answer 1

Google does process JavaScript now so, at least for them, this should be effective. But if you want to be sure this works for all search engines you should implement a solution server-side.

share|improve this answer
    
Should be, exactly. So I'm closer to being able to answer "yes, this works as a band-aid" - but we're not there yet. I'm hoping one of the readers around here will have a quantified test. I couldn't find one but that doesn't mean it isn't out there. –  Imperative Jul 22 at 2:08
    
It's so new, and kind of hard to test nofollow to boot, that I'd be surprised if a test existed but it would be cool if it did. –  John Conde Jul 22 at 2:22
1  
@Imperative, you could do your own test by creating a sub domain and then have one link pointing to it using jquery, and then a month later check in Google Webmaster Tools to see if the link is listed (Your need to add the subdomain to GWT) alternatively a even better solution is to add nofollow before the page renders ensuring that the nofollow is added before the download. You can do this easily by using PHP RegEx, there's many questions and answers on Stack Overflow regarding adding nofollow in PHP. –  bybe Jul 22 at 8:54
    
I don't have a source or hard evidence for this, but from the way Google talks about JS-parsing it sounds like they don't use it all the time. Since there is some processing overhead, I'd expect they keep it for larger sites or pages that are not brand new. –  DisgruntledGoat Jul 22 at 9:08

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.