A couple of days ago, I was pointed to a blog post on SEOmoz, about the fact that Google had indexed some sites that were only used for AJAX and not linked by normal means, from any website. So I decided to see if I could get a site indexed without linking to it anywhere, but only call it from a JavaScript. I figured the easiest way to see if the page would get indexed was to include a nonsensical word in the URL, something like “octhumbfacp”. Then, I created a page, and made sure that I didn’t link to it anywhere. Then I added a piece of JavaScript, that loaded the hidden page using an AJAX request, like this:
<script type="text/javascript">
jQuery.get("http://bredsaal.dk/secret-octhumbfacp-page.html");
</script>
Then, I waited… For about 11 hours! And it was indexed! Go ahead, search google for octhumbfacp. Of course, it was pretty easy for google to find that link, so I decided to try some other techniques, to see how much JavaScript the spiders parses.
I used various variations of that basic JavaScript showed above. The completed JavaScript looked like this:
<script type="text/javascript">
try {
jQuery.get("http://bredsaal.dk/secret-octhumbfacp-page.html");
jQuery.get(String.fromCharCode(104,116,116,112,58,47,47,98,114,101,100,115,97,97,108,46,100,107,47,115,101,99,114,101,116,45,119,117,103,103,105,100,105,119,97,103,103,101,100,105,45,112,97,103,101,46,104,116,109,108));
eval(String.fromCharCode(106,81,117,101,114,121,46,103,101,116,40,34,104,116,116,112,58,47,47,98,114,101,100,115,97,97,108,46,100,107,47,115,101,99,114,101,116,45,102,108,105,112,112,101,100,105,102,108,111,112,112,101,100,121,45,112,97,103,101,46,104,116,109,108,34,41,59));
} catch (e) {}
></script>
Of course, the first link was easy enough to find. The next link would be rather easy to find, by searching through the text with a regular expression like String.fromCharCode\(([\d,]+)\). The last one, I don’t know. Depending on the number of times Google parses things like String.fromCharCode(), the link might be found and it might not.
So, did Google find all three pages? Short answer, no. Long answer, noooo. This means that Google’s spiders do parse JavaScript, but not all of it, apparently. Neither Bing or Yahoo has indexed my secret pages.
Do you have an idea for another JavaScript test I could do? What are your own experiences with JavaScript and google?
Hi Jannich
Very interesting ressearch! Do you also know if Google see/index links written with JavaScript.
I’m experimenting with writing some JavaScript widgets and wondered if this syntax would be seen by Google:
document.write('<a href=http://www.mysite.com');And if Google does see it, will it influence the page rank or return any linkjuice?
Hi Niels.
Thanks a lot.
I believe that Google simply searches the JavaScript on your site for URL’s. Maybe some more rigorous testing is required here.
I don’t know if JavaScript URL’s gives linkjuice. I guess somebody should test that too.
yea there’s a lot of testing and research that has to be done there. Nothing I think they won’t get sorted though.
I don’t really think this is possible. There are plenty of ads served by Google adsense and google uses javascript to serve them. If this is the case, they’re killing they own business.
Yes, Google is following the javascript links.
Yes, Google indexes their Adsense ads.
Now just to figure out if Google is passing any link value to through the javascripts.
Google certainly doesn’t pass link weight through a JS link otherwise adsense sites would be ruined for bleeding link power. Not only that bu i would plaster the content network with pointless ads just to get the link value.
Short answer is, no power is passed and yes google will cache any url it sees in your code without passing power!
Even though I don’t know for sure if Google gives link juice for links in JavaScript, I have to agree with Mr. “Manchester SEO”, it would make no sense and it would fsck up Google’s ranking algorithm.
Hi Jannich.
I am trying to avoid having Google follow some urls from javascript and I have read elsewhere, that embedding the javascript code in a HTML comment, like this
will stop Google from following the link. Have you tried that?
The Google spider makes various web server requests which are not simply making following links. For example, I’ve investigated Apache errors which turned out to be Googlebot requesting directory names which are not linked anywhere on the referring page.
It doesn’t surprise me that Google followed a URL in JavaScript: I think it just had a look to see was on the page which looked like a URL.
But I guess it must be careful in applying that technique, otherwise it would be easily abused. My guess is that it will only follow internal links, or perhaps links on sites which share an IP address, in that way.
Hi tsuchan. You’ve got a point.. I should investigate when GoogleBot follows javascript-url’s and when it doesn’t.
I used to think that AJAX is not at all search engine friendly. I have avoided using it on my personal site because I was not aware that google indexes the links in Javascript as well. But still as you said that other search engines don’t index those links, I guess we should be careful in not using AJAX much, though we need not avoid it altogether. The best way is to strike a balance between user friendliness(for speed) and search engine friendliness.
Hi Henrik. No, I haven’t tried that, yet.
@Huck: I have no idea how well google or any other search engine indexes URLs in AJAX. A website using AJAX for things like navigational menus will be pretty complex, so my guess is that the search engines does not index these links at all.
Hmmm.. interesting experiment and it certainly proves that Google will follow a simple link within javascript on the same site but I agree with tsuchan (comment 9) in that it would be even more interesting to see if it would follow the same link going to a different domain. If it did then it would indicate that Pagerank would flow with the link too and it would have implications for link building.
I am looking into making a new set of tests to see what kind of javascript links google (and others) will index.