Will Google Count Links Loaded from JavaScript Files After the Page Loads
-
Hi,
I have a simple question. If I want to put an image with a link to another site like a banner ad on my page, but do not want it counted by Google. Can I simply load the link and banner using jQuery onload from a separate .js file?
The ideal result would be for Google to index a script tag instead of a link.
-
Good Answer. I completely abandoned the banner I was thinking of using. It was from one of those directories that will list your site for free if you show their banner on your site. Their code of course had a link to them with some optimized text. I was looking for a way to display the banner without becoming a link farm for them.
Then I just decided that I did not want that kind of thing on my site even if it is in a javascript onload event if Google is going to crawl it anyway, so I just decided not to add it.
Then I started thinking about user generated links. How could I let people cite a source in a way that the user can click on without exposing my site to hosting spammy links. I originally used an ASP.Net linkbutton with a confirm button extender from the AJAX Control ToolKit that would display the url and ask the user if they wanted to go there. Then they would click the confirm button and be redirected. The problem was that the URL of the page was in the head part of the DOM.
I replaced that with a feature using a modal popup that calls a javascript function when the link button is clicked. That function then makes an ajax call to a webservice that gets the link from the database. Then the javascript writes an iframe to a div in the modal's panel. The result should be the user being able to see the source without leaving the site, but a lot of sites appear to be blocking the frame by using stuff like X-Frame-Options, so I'm probably going to use a different solution that uses the modal without the iframe. I am thinking of maybe using something like curl to grab content from the page to write to the modal panel along with a clickable link. All of this of course after the user clicks the linkbutton so none of that will be in the source code when the page loads.
-
I think what we really need to understand is, what is the purpose of hiding the link from Google? If it's to prevent the discovery of a URL or prevent the indexation of a certain page (or set of pages) - it's easier to achieve the same thing by using Meta no-index directives or wildcard-based robots.txt rules or by simply denying Gooblebot's user-agent, access to certain pages entirely
Is is that important to hide the link, or is it that you want to prevent access to certain URLs from within Google's SERPs? Another option is obviously to block users / sessions referred from Google (specifically) from accessing the pages. There's lots can be done, but a bit of context would be cool
By the way, no-follow does not prevent Google from following links. It actually just stops PageRank from passing across. I know, it was named wrong
-
What about a form action? Where instead of an a element with a href attribute you add a form element with an action attribute to what the href would be in a link.
-
Thanks for that answer. You obviously know a lot about this issue. I guess they would be able to tell if the .js script file creates an a element with a specific href attribute and then add that element to a specific div tag after the page loads.
It sounds like it might be easier just to nofollow those links instead of going to all the trouble to redirect the .js file whenever Google Bot crawls the page. I fear that could be considered cloaking.
Another possibility would be a an alert that requires a user interaction before grabbing a url from a database. The user would click on the link without an href, the javascript onclick fires, the javascript grabs the the url from a database, the user is asked to click a button if they want to proceed, and then the user is redirected to the external url. That should keep the external URL out of the script code.
-
Google can crawl JavaScript and its contents, but most of the time they are unlikely to do so. In order to do this, Google has to do more than just a basic source code scrape. Like everyone else seeking to scrape data from inside of generated elements, Google has to actually check the modified source-code, after all of the scripts have run (the render) rather than the base (non-modified) source code before any scripts fire
Google's mission is to index the web. There's no doubt that, non-rendered crawls (which do not contain the generated HTML output of scripts) can be done in a fraction of the time it takes to get a rendered snapshot of the page-code. On average I have found rendered crawling to take 7x to 10x longer than basic source scraping
What we have found is that Google are indeed, capable of crawling generated text and links and stuff... but they won't do this all the time, or for everyone. Those resources are more precious to Google and they crawl more sparingly in that manner
If you deployed the link in the manner which you have described, my anticipation is that Google would not notice or evaluate the link for a month or two (if you're not super popular). Eventually, they would determine the presence of the link - at which point it would be factored and / or evaluated
I suppose you could embed the script as a link to a '.js' module, and then use Robots.txt to ban Google from crawling that particular JavaScript file. If they chose to obey that directive, the link would pretty much remain hidden from them. But remember, it's only a directive!
If you wanted to be super harsh you could block Googlebot (user agent) from that JS file and do something like, 301 them to the homepage when they tried to access it (instead of allowing them to open and read the JS file). That would be pretty hardcore but would stand a higher chance of actually working
Think about this kind of stuff though. It would be pretty irregular to go to such extremes and I'm not certain what the consequences of such action(s) would be
Got a burning SEO question?
Subscribe to Moz Pro to gain full access to Q&A, answer questions, and ask your own.
Browse Questions
Explore more categories
-
Moz Tools
Chat with the community about the Moz tools.
-
SEO Tactics
Discuss the SEO process with fellow marketers
-
Community
Discuss industry events, jobs, and news!
-
Digital Marketing
Chat about tactics outside of SEO
-
Research & Trends
Dive into research and trends in the search industry.
-
Support
Connect on product support and feature requests.
Related Questions
-
Homepage canonical url with splash or not with splash? All other links are without but logo links with splash
Hello, There is so much contradicting information about the homepage canonical URL. Many websites have all the links without the trailing splash but their homepage URL still contains the splash. Now Moz is an example with this. Their urls don't have the splash, and their canonical does not have the splash. Why is it so and why so much different ways people have it?
On-Page Optimization | | advertisingcloud0 -
Grade F page on Moz positions No 1 on Google Keywords not contained
Hi I am trying to understand why a page list in position 1 on Google despite the fact it does not include the search terms anywhere in the page source. One of our sites has been in that position for years has great content and links for the key word terms so how can the other page overtake it and all of the other keywords without so much as a sniff of the keyword in the URL, Meta, content or images. It grades F on Moz! How can I discover the technique that has been used. This really is black art stuff or do Google accept payment from major corporations to list their pages irrespective of content?
On-Page Optimization | | Eff-Commerce0 -
Google Indexed = 35, 445 pages, Bing Indexed = 243 pages... Why?
Dear MozSquad, Can anyone check our site and let me know if there's anything super apparent that would cause Bing to treat us like a bum on the street? I recently made some structural changes which really helped with Google, but Bing didn't even budge. It's a lot harder to keep up with all the SEO initiatives I have in mind with it being a small start-up where I'm responsible for planning the entire Internet Marketing campaign, giving constant input on UX and site design, etc on top of 900 other things, so I figured it'd be a good time to use The Moz to help a brother out. Ideas? Domain: homeandgardendesignideas.com (yeah, I know it's a little long =P)
On-Page Optimization | | zDucketz0 -
What is everyone doing to reduce the number of links on a page?
Some clients of mine have sites that are throwing the "too many links on one page" error and we're not just talking a little more than the status quo 100 links, it's much more. I believe it could be due to the fly-out navigation. My Solution: shorten the Tier 2 categories in the left nav down to 5 and add a "View All" link after the 5th and remove top nav fly-outs. I'm not sure if these are best practices or the best for usability though?
On-Page Optimization | | LisaS130 -
Keyword Placement in Page Title - will changing it make a big difference?
Hiya guys I've noticed since changing my Title of my forum from: Talk Nightlife | Nightlife and Clubbing forum for the UK to Talk Nightlife | Nightlife Forum and Clubbing Guide for the UK (current) ... That its jumped from 22nd to 10th in google for term "nightlife forum" Am wondering, because of the on site optimisation tool telling me I should put the keyword to the front to something like eg: Nightlife Forum | Talk Nightlife Clubbing Guide for the UK Will changing the Keyword and putting it to front of the Title make a big difference? Your thoughts please guys Cheers Luke
On-Page Optimization | | Lukescotty0 -
Google found bad links delete them or 301 redirect?
we went into our google account and saw about 70 bad links that they found on our site. what's the best thing to do, seo-wise: should we go into the pages that have the bad links and delete them from the html code, or re-direct them in our htaccess script?
On-Page Optimization | | DerekM880 -
Do footer links apply too many on-page links?
We tend to put a a lot of links in the footers of some of our websites (e.g. www.AlohaWhistler.com). Our CAMPAIGNS report is showing that several pages on such sites have "too many on-page links". We understand the logic that having more than 100 links per page is "too much". Does this also apply to footer links?
On-Page Optimization | | RoyMcClean0 -
Prevent link juice to flow on low-value pages
Hello there! Most of the websites have links to low-value pages in their main navigation (header or footer)... thus, available through every other pages. I especially think about "Conditions of Use" or "Privacy Notice" pages, which have no value for SEO. What I would like, is to prevent link juice to flow into those pages... but still keep the links for visitors. What is the best way to achieve this? Put a rel="nofollow" attribute on those links? Put a "robots" meta tag containing "noindex,nofollow" on those pages? Put a "Disallow" for those pages in a "robots.txt" file? Use efficient Javascript links? (that crawlers won't be able to follow)
On-Page Optimization | | jonigunneweg0