问题
For SEO, I have been tasked with adding a rel="nofollow"
to all external links*.
The simplest and least obtrusive way to add rel="nofollow"
to each external link is with some jQuery. I've done this fine but I'm now wondering:
Does Google see changes made during jQuery's document load to the DOM (such as this one) or does it only see the original source code?
I don't want to discuss why this is a bad idea or not. This is an SEO consultant's decision and I've learnt that unless implementation of their latest whim takes too much time to just go along with what they want
回答1:
It looks like Google spider does execute some JavaScript, but I do not believe it would execute large libraries like jQuery..
Please check interview with Matt Cutts
Matt Cutts: "For a while, we were scanning within JavaScript, and we were looking for links. Google has gotten smarter about JavaScript and can execute some JavaScript. I wouldn't say that we execute all JavaScript, so there are some conditions in which we don't execute JavaScript. Certainly there are some common, well-known JavaScript things like Google Analytics, which you wouldn't even want to execute because you wouldn't want to try to generate phantom visits from Googlebot into your Google Analytics".
There are also some additional details on Google Spider improvements (JavaScript/AJAX support) on Google Webmaster Central Blog
回答2:
Just FYI for others that bump into this page.
I had a similar question where I didn't want the content injected in the DOM to be indexed.
TL;DR
"After searching for a long time I finally found this page from Google Support themselves: Can Google Site Search index JavaScript content on my pages?
This is exactly what they say in that page... short answer: No, it cannot index content inside JavaScript:
"Google Custom Search can't index content contained in JavaScript. The general rule for making sure that a web page can be indexed by Google is to ensure that all of the text that needs to be indexed is visible in a text-based browser, or a browser with JavaScript turned off."
"
--
Here's the link to my post: Inject content/HTML without altering the DOM
回答3:
Yes, the Googlebot can see the changes you make to the DOM with JavaScript.
Roughly speaking you just have to make sure
- that your code is executed before or on the
window.load
event (i.e. use$().ready(...)
) - and you don't do AJAX calls.
To get a better understanding about the details you may read my blog article.
来源:https://stackoverflow.com/questions/14336017/will-googlebot-crawl-changes-to-the-dom-made-with-javascript