In the world of SEO, links are the pathways that search engines use to discover and understand your content. For a link to be effective, it must have a crawlable `href` attribute in the initial HTML. JavaScript links are links that rely on a script to function, often by using an `onClick` event instead of a standard `href`. This is a major SEO issue, as it can be difficult for search engines to find and follow these links, which can prevent them from discovering your content and passing PageRank.

Think of your website as a library. A standard HTML link is a clearly labeled book on the shelf. A JavaScript link is a book that is invisible until you ask the librarian to perform a special trick. By fixing any JavaScript links that may be present, you can create a more successful and user-friendly experience for everyone. For a deeper dive into the world of linking, see our article on the links category.

An illustration of a hidden link, symbolizing the importance of fixing JavaScript links.

Why JavaScript Links Are a Problem for SEO

Relying on JavaScript for your primary navigation is a risky practice. As detailed in this guide to JavaScript SEO from Moz, anything that is not in the initial HTML source is harder for search engines to process.

  • No `href` Attribute: Search engines find new pages by crawling `href` attributes. If a link is just a `<span>` with an `onClick` event, it’s not a true link to a crawler.
  • Delayed Discovery: Even if JavaScript later adds an `href`, it’s subject to the two-wave indexing process, delaying discovery.
  • No PageRank Flow: PageRank is primarily passed through `href` links. JavaScript links may not pass authority, which can harm your site’s internal linking structure.

How to Make Your Links Crawlable

The fix for this issue is to always use a standard `<a href=”…”>` tag for your links. This ensures that search engines can see the link immediately upon crawling the page. For Google’s official guidance, see their documentation on JavaScript SEO.

<!-- Before: Uncrawlable JavaScript link -->
<span onclick="goToPage('/my-page/')">Go to My Page</span>
<!-- After: Crawlable HTML link -->
<a href="/my-page/">Go to My Page</a>
An illustration of a checklist, symbolizing the importance of making sure your website is free of JavaScript links.

Frequently Asked Questions

What are JavaScript links?

JavaScript links are links that rely on a script to function, often by using an `onClick` event instead of a standard `href` attribute. For SEO, the most problematic type is a link that is missing a crawlable `href` attribute in the initial HTML.

Can Google follow JavaScript links?

Yes, Google can render JavaScript and discover links that are added to the DOM. However, this relies on the second wave of indexing and is not as reliable as a standard `<a href=\”…\”>` link in the initial HTML. For PageRank to flow and for the most reliable crawling, a proper `href` attribute is essential.

How do I fix JavaScript links?

The best way to fix JavaScript links is to replace them with standard HTML `<a>` tags that have a crawlable `href` attribute. If you need to add dynamic functionality, you can still use JavaScript, but the `href` should be present as a fallback.

Ready to unhide your links? Start your Creeper audit today and see how you can improve your website’s JavaScript SEO.