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
-
Will shortening down the amount of text on my pages affect it's SEO performance?
My website has several pages with a lot of text that becomes pretty boring. I'm looking at shortening down the amount of copy on each page but then within the updated, shortened copy, integrating more target keywords naturally. Will shortening down the current copy have a negative effect on my SEO performance?
On-Page Optimization | | Liquid20150 -
Moving from Bigcommerce to Woocommerce on WP. Should we redirect size pages into one page?
We are moving from Bigcommerce to Woocommerce on WP. On Bigcommerce, due to some bizarre reasoning the previous developer had 3 separate URLS for the same product in different sizes - S, M and L. Now we plan to have one product page where the sizes can be selected and 301 redirect the 3 urls to the new one. Is this advisable? Or should we just have 3 separate pages. OR should we have one of the sizes pages as the new page and then redirect the other 2 to this one? I ask this because the site has a LOT of ranking power and we do not want to jeopardise that.
On-Page Optimization | | MashBonigala0 -
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 -
Too Many On-Page Links
If a page has more than 100 links, rather than splitting up the page into multiple pages, is it ok to use name="robots" content="noindex, follow" />? The page in question lists links to articles so the page itself isn't that important to appear in serps, but the articles are the helpful content pages: www.ides.com/articles/processing/injection-molding/
On-Page Optimization | | Prospector-Plastics0 -
Why doe SEOmoz include my categories and subcategories when counting on page links?
Hi everyone, I am new to SEOMOZ, but it looks like really good program. I ran a report last week, and SEOMOZ says that out of 10001 pages, I hve a total of 9995 warnings. When I take a look at the breakdown, it says I have too many on page links. I removed the links from the bottom of each page, but my on page links are still over 100. Does this mean that I will have to get rid of categories and sub-categories in the navigation bar? Thanks, Don
On-Page Optimization | | ge01734000 -
Why a page with an On Page A grade has a less good rank than a page with a F grade?
Why a page with an On Page A grade is ranked 17 in Google when the home page with a F grade is ranked 9 ? Thanks
On-Page Optimization | | Amadeus_eBC0 -
Should one page with markers or six separate pages?
Hi - I'm working on a site that was set up with 6 bios on one page, with markers jumping to each person's name. I was thinking about separating those into 6 different pages, but not sure if that's the right thing to do. Advice about keeping the bios on one page vs splitting them up? (Am I more likely to rank for those peoples' names if I have a unique page, or is the one page url with each different marker in it, just as good?) Ranking well for those names isn't a huge goal of the site, but it would be nice to make the choice that would help with that rank. Thanks for your input Emma
On-Page Optimization | | emmas0 -
Too many on page links
Our home page (and 1400 of our other pages) have well over 100 links, going beyond the recommend amount. Our competitors have less on page links (to other pages on their site) and way more link popularity so we are trying to figure out the best solution for this without hurting our sites conversions and usbaility.
On-Page Optimization | | iAnalyst.com0