Skip to main content

Can Google Crawl JavaScript Links? How to Check Yours

admin8 min read
Illustration showing how can Google crawl JavaScript links through connected page bridges

Can Google crawl JavaScript links? Yes, in most cases it can. Google Search Central says links inserted by JavaScript are crawlable when the rendered page contains an HTML anchor element with an href attribute that resolves to a web address. The catch is in that wording. A button, a span or a script-driven click handler is not a link, even if a visitor can click it and land on a new page.

In this guide I show how to separate real links from lookalikes, how initial HTML and rendered HTML differ, and how to compare a link inventory with Google’s rendered view of the same page. I also explain why one tool missing a link does not prove Google cannot see it.

Illustration of a crawler following connected links from a web page

Google Search Central’s link guidance says Google extracts links from the initial HTML and again after rendering. If your script builds an anchor with a valid href, that anchor appears in the rendered page and Google can treat it as a link. The way the link was created (server template or browser script) matters less than what the final markup looks like.

Two details deserve attention:

  • The element must be an anchor with an href. The destination has to be a URL Google can resolve, not a fragment of script logic.
  • Rendering can happen later than the first fetch. Google’s JavaScript SEO documentation describes rendering as a separate step, so links placed in the initial HTML where practical depend less on that second step.

This answer does not promise that a discovered link will be crawled quickly, that its destination will be indexed or that it will rank. It only says the link is eligible to be discovered.

The safest pattern is a plain anchor whose href holds the destination. This works whether the HTML arrives from the server or JavaScript inserts it into the page.

<a href="/products">Products</a>

You can still attach a click handler to that anchor for animations or client-side routing, because the destination remains in the markup:

<a href="/products" onclick="goTo('products')">Products</a>

Google’s documentation lists patterns that you should not rely on for link discovery:

<a routerLink="products">Products</a>
<span href="/products">Products</span>
<a onclick="goTo('products')">Products</a>
<a href="javascript:goTo('products')">Products</a>
<a href="javascript:void(0)">Products</a>

Google says it cannot reliably extract URLs from href-less anchors or script-driven navigation elements, although it may sometimes parse a nonrecommended format. Treat that as luck, not a plan.

Here is a JavaScript example that creates a fully crawlable link:

const link = document.createElement('a');
link.href = '/products';
link.textContent = 'Products';
document.querySelector('nav').append(link);

A menu button can legitimately be a button that opens and closes a menu. The destinations inside that menu should still be real anchors. If you want a quick list of what a page exposes, the Link Extractor lists the links and anchor text it finds on a URL, which helps you spot destinations that are missing from the markup it reads.

Blueprint turning into a finished building to show initial versus rendered HTML

How Initial HTML and Rendered HTML Differ

The initial HTML is what the server returns before any script runs. The rendered HTML is the document after a browser-like renderer has executed JavaScript. A link that only exists after a script runs will be present in the rendered version and absent from the initial one.

Google’s JavaScript SEO basics describe this two-stage flow: Google can extract links from the initial response, then render the page and extract again. Because rendering may occur later, a navigation menu that arrives only through script depends on that extra step before its destinations are seen. I do not put a number on the delay, since Google does not publish one for me to cite.

This is why I keep primary navigation, category links and pagination in the initial HTML wherever the stack allows it. Server-rendered or pre-rendered markup is a practical way to do that. It is not mandatory, but it reduces the number of things that have to go right.

Also remember that rendering needs access to resources. If a script file that builds your menu is blocked, the renderer may never produce the anchors.

This audit compares two different observations of the same page. Use it on a page you control, because URL Inspection requires a verified Search Console property.

  1. Inventory the links. Enter the source page’s public URL in the AllEasySEO Link Analyzer and record the destinations and anchor text it reports. Its page describes internal and external link analysis, dofollow and nofollow attributes and broken link detection. It does not state that the tool executes JavaScript or reproduces Googlebot rendering, so treat the result as one view of the page, not as Google’s view.
  2. Inspect the same URL in Search Console. Open the URL Inspection tool, run Test live URL, then choose View tested page. On the HTML tab, search for the expected <a href="..."> and the destination path. Check the screenshot, the loaded resources and any JavaScript errors. If the URL is already indexed, compare it with View crawled page, keeping in mind that crawl may predate a recent change.
  3. Compare the two lists. Every destination should be in the rendered HTML as a valid anchor. If the analyzer omitted a link that appears in Google’s rendered HTML, investigate why the tools differ instead of concluding Google cannot see it. If the link is missing from the rendered HTML too, move on to troubleshooting.

For a quick look at raw crawler-style output, the Spider Simulator shows the content, links and metadata it can read from a page. Its description says it helps identify JavaScript-dependent elements, but it is a simulation, not Googlebot.

A live inspection tests that one rendering instance. It does not guarantee later crawling, indexing or ranking of the destination.

If the destination is absent from the tested page’s HTML tab, work through these causes in order:

  1. Blocked resources. Check the loaded resources list in URL Inspection for blocked scripts or API calls. You can test a script or endpoint path with the Robots.txt Tester to see whether Googlebot is allowed to fetch it.
  2. Rendering errors. Look at the JavaScript console messages in the tested page details. A thrown error before your menu code runs can leave the navigation empty.
  3. Interaction-dependent links. If anchors appear only after a click, hover or scroll, the renderer may never see them. Put the anchors in the page at load and use script only to show or hide them.
  4. Wrong element. Confirm the markup is an a element with an href, not a div or span with a handler.

Once links appear correctly, run the Broken Links Finder on the page. It scans for 404 errors, dead URLs and redirect issues, which helps confirm that the anchors you exposed actually lead to working pages.

Single-Page Apps and Client-Side Routing

Single-page applications are where the question of whether Google can crawl JavaScript links comes up most often. Google’s JavaScript SEO basics recommend giving each view a real URL and linking to it with anchors. Fragment-only routes such as /#/products are not what I would use for content you want discovered, because the fragment is not a separate page path.

Instead, use the History API so each route has a normal path, and render navigation as anchors that carry the path in href. The router can intercept the click for a smooth transition while the markup still names the destination. Check every main route in URL Inspection after a deployment, since a framework upgrade can quietly change how links are output.

Frequently asked questions

Can Google crawl JavaScript links added after the page loads?

Yes, if the script produces an anchor element with a valid href in the rendered page. Google Search Central says it extracts links from the initial HTML and again after rendering. Links that appear only after a click or other interaction are less dependable.

Does an onclick handler count as a link for Google?

Not by itself. Google says it cannot reliably extract URLs from script-driven navigation elements. An anchor with both an href and an onclick handler is fine, because the destination remains in the markup.

Is href="javascript:void(0)" crawlable?

No, it contains no destination URL. Google lists javascript: hrefs among the formats you should not rely on for link discovery. Use a real path in the href and add behavior separately.

If Link Analyzer misses a link, can Google not see it?

Not necessarily. The tool’s page describes link and anchor-text analysis, but does not say it runs JavaScript like Googlebot. Check the rendered HTML in URL Inspection before concluding anything.

How do I check the rendered HTML in Search Console?

Inspect the page URL, run Test live URL, then open View tested page and use the HTML tab to search for your anchor and destination. You can also review the screenshot, loaded resources and JavaScript errors.

Should I put important links in the initial HTML?

Where practical, yes. Because rendering can happen after the first fetch, placing key navigation in the initial HTML reduces your dependence on that later step.

Do fragment URLs work for single-page app navigation?

They are not a good choice for content you want found. Use real paths with the History API and anchors that carry those paths in href, as Google’s JavaScript SEO guidance suggests.

Next steps

So, can Google crawl JavaScript links? Yes, provided the rendered page contains an anchor with a resolvable href. Click handlers, href-less elements and javascript: URLs should not carry your navigation. Build an inventory of your links, verify the rendered HTML in Search Console’s URL Inspection tool, and remember that a live test shows one rendering, not a promise of indexing. When two tools disagree, investigate the difference before you change anything.

Related tools and resources on AllEasySEO:

Sources and further reading

Try these free SEO tools

Free, browser-based and no signup needed.

See all free SEO tools