Subscribe via

Using jQuery to Easily Dofollow/Nofollow Links

This might be old news to you, but you should know that the Googlebot now follow links created by Javascript. I have seen evidence of this myself and was starting to get frustrated that I would have to reevaluate my site and patch any leaking link juice from Javascript links. Before I got to the point of full frustration, I realized that I can use this Googlebot “feature” to my advantage and use Javascript itself to easily correct this leaking link juice problem.

Finding Dofollow Links

Before correcting them, we have to find them! I use the awesome SearchStatus Firefox add-on to hunt down any unintentional dofollow links. After installing the plugin, I just enable the “Highlight Nofollow Links” feature by right clicking on the @ symbol on the bottom right of Firefox.
SearchStatus Options
After enabling the “Highlight Nofollow Links” feature, you will see that all nofollow links will be highlighted red.
Nofollow Page

Nofollow Using jQuery Magic

The beautiful thing about jQuery is its ability to perform operations on multiple things with a single line of code. I can abuse this feature to help me set all links in any HTML block with a rel=”nofollow”. Just to give you an idea of how easy and powerful this is, this is the line I use to nofollow all links in my Intense Debate comment form:

$(".comment_form a").attr("rel", "nofollow");

To dofollow a certain set of links, you can do something like the following:

$(".blogroll a").attr("rel", "");

Easy isn’t it? No plugin hacking, no search and replace, and no hassle!

(For those of you who are not the jQuery type, you can take a look at the jQuery selector documentation to figure out the meaning of “.comment_form a”.)


In this section, I will show you how to get jQuery code to run on every page load.

  • Download nofollow.js and place it anywhere on your server as a base to start from.
  • Modify nofollow.js using jQuery to follow/nofollow any links as you see fit.
  • Refer to nofollow.js in the footer of your template. For example:
    <script type="text/javascript" src="/path/to/your/nofollow.js"></script>

Final Thoughts

After realizing the power of jQuery and this Googlebot feature, patching leaking PR link juice isn’t that bad after all.

Do you guys have a better method of doing this? Do you disagree with my Googlebot findings? Do you know any other search engines that follow Javascript links? Please let me know in the comments section.

24 Responses to “Using jQuery to Easily Dofollow/Nofollow Links”

[go to last comment]
  1. redwall_hp

    Why would you use JavaScript to add NoFollows? Search engines don't execute JS, and will just read them as DoFollows…

  2. Ty Bone

    Googlebot does execute Javascript and follow links generated by Javascript and I also I think there is a strong trend in other search engines moving towards JS execution to resolve links.

  3. redwall_hp

    Really? When did they add that feature…?

  4. Ty Bone

    I think it's been a while (See first link of this article). I started noticing when my Google Webmaster Central reported "Not Founds" from my ever-changing Javascript BSA ad URLs.

  5. redwall_hp

    Well… *That* certainly is interesting.

  6. Artem Russakovskii

    Let's see some links proving or disproving the above, please.

  7. Ty Bone

    Also… if I only have dofollow links generated by Javascript. I think it's safe to just disable those via Javascript itself :).

  8. Pet Snakes

    You mentioned "leaking juice" via dofollow links. My understanding was that page rank is determined by incoming links and outgoing links don't affect the page's rank they come from only how much "juice" each link gets.

  9. Ty Bone

    @Pet Snakes
    The whole topic is certainly highly debated. Regardless, nofollow plays an important role in controlling which result page gets the most juice. If I link to somebody externally, I would want to do them the favor of passing a really juicy link rather than a less juicy one (caused by a bunch of my other dofollow internal links to useless page).

    Here is some more info from seomoz (…

  10. Pet Snakes

    Thanks. I'll have a look at the link.

  11. Texas dev

    It's rather interesting, does jQuery Magic tool allows adding do-follow links manually?

    Now I share the opinion that javascript-generated links are checked by Google. That's why no fear that javascript based menu can harm your sites positions in search engines.

  12. Wes

    If this works it will save me heaps of time. This is very helpful for working with websites that work with content dynamically generated.

  13. wes

    Just to confirm… this will change all targeted links into nofollow links AND google will treat them properly as nofollow links? Does this only apply to links within javascript or can it be used for all links?

  14. Ty Bone

    That is correct, google will treat them properly as nofollow links. It can be used with all links.

  15. Mack

    I also use NoDoFollow Firefox add-on. It works wonders for me.

  16. R4ds

    Your article clearly describe the advantage of do follow links.

  17. diagnostic vente

    Why would you use JavaScript to add NoFollows? Search engines don't execute JS, and will just read them as DoFollows…
    + 1000

  18. Ty Bone

    Dude… read the first sentence of the article.

  19. diagnostic vente

    Google follow javascript link but nobody said it takes care about nofollow add by javascript.

  20. Ty Bone

    Why wouldn't they? It seems pretty easy to do and that is their business. I'd imagine their crawler to do something like:

    1. Fetch page
    2. Evaluate JavaScript
    3. Analyze HTML for content, links w/ nofollow, etc.
    4. ???
    5. ???
    6. Profit!

    If they dofollow all JavaScript links even if there is a nofollow tag on those links, then we are in trouble if we use 3rd party comment platforms like Disqus & Intense Debate (have dofollow links in the comment thread). You would be leaking all kinds of link juice if Google didn't abide to nofollow in JavaScript.

    Given how easy it is to do it, it wouldn't hurt to nofollow all those links by JavaScript.

  21. diagnostic vente

    If you want to be sure and not make mistake put all html link in nofollow and add java to tranform these link in dofollow.

    But PR sculpting is dead since google take nofollow link to remove juice.…

  22. HD Wallpapers Admin

    Great script. I need that so much.
    I looked over a week for something like this.
    Thank you!

  23. fxgeorges

    I've updated the script so that it will correctly highlight links which have the string "nofollow" anywhere in the rel attribute.
    Edit: Just to add, you'll need to visit the page linked above and add it to your favourites again to get the updated version.

  24. Aran Seaman

    I have installed this and it does not seem to work. I should be able to see the “rel=”nofollow” appearing on the links of the intense debate commenter’s profiles, right?

[go to first comment]

Leave a Reply