Yes, but inserting a link with JavaScript does not automatically make it crawlable. According to Google’s official documentation, a crawlable link should be an a element with an href pointing to a URL that can actually be requested. If JavaScript inserts the link into the DOM, Google must also be able to execute the relevant scripts. Even links added inside jQuery’s $(document).ready() meet its guidelines for crawlable links when these conditions are met. What matters is the generated link format and rendered output, not which function is used. This does not mean that all search engines can handle such links.
Google can discover links after rendering, but that does not mean it will crawl them immediately
Googlebot first fetches a page, parses the links in its HTML, and adds the URLs it finds to the crawl queue. If links are generated by JavaScript rather than included in the initial HTML, rendering is required: after executing the scripts, Google parses the rendered HTML again to find the links.
However, rendering may not begin immediately, and not every page will be rendered. The official documentation notes that the wait may be a few seconds or longer. Google will not render pages blocked by robots.txt or execute JavaScript files blocked by robots.txt. It may also skip rendering pages with non-200 status codes. A link being parseable, a URL entering the crawl queue, and a destination page being indexed are separate things. A parseable link is not a promise of indexing.
Dynamically added links should be a elements with real URLs
Whether you use native JavaScript or jQuery, the resulting HTML should meet the same requirements. For a product category, for example, you could generate markup like this: <a href=”/products/category/shoes”>Shoe category</a>. The href provides the destination, while the link text describes the page’s content.
- Use an a element with an href: Setting only an onclick on an a element, or adding an href to a span, does not match the officially recommended crawlable format.
- Provide a resolvable URL: Either a full URL or a relative URL such as /products is acceptable; do not replace the destination with javascript:goTo(‘products’).
- Interactivity can stay: An a element with a valid href can still use onclick. The issue is not whether an event handler exists, but whether navigation relies solely on it.
Google may still attempt to parse formats it does not recommend, but you should not rely on that possibility. If link text is also inserted by JavaScript, the official recommendation is to use the URL Inspection tool to confirm that the text appears in the rendered HTML.
Put important links in the HTML first, then add interactivity
Google still recommends server-side rendering or pre-rendering to make content available to users and crawlers sooner, and because not all crawlers can execute JavaScript. Important navigation does not have to wait for scripts to run before appearing.
Public discussions also suggest progressive enhancement: first include links with destinations, such as “Services” and “About Us,” in the HTML, then use JavaScript to add AJAX interactions. This is implementation advice, not an official rule. Unlike inserting links entirely through JavaScript, this approach provides them in the original HTML, so crawlers do not need to execute scripts to find the URLs.
JavaScript-inserted links: perspectives from across the web
How can infinite-scroll pages make links easier to discover?
Provide plain HTML pagination for infinite-scroll content so crawlers do not have to rely entirely on dynamic loading to discover other pages. When using Intersection Observer, also ensure that the initially loaded content is crawlable. This is design advice for pages that use lazy loading, not a guarantee that every paginated page will be crawled or indexed.
Do SEO tools also count links inserted by JavaScript?
There is no single answer. In a 2021 article, Ahrefs stated that its regular web crawls at the time covered only some JavaScript-inserted links and counted only HTML a elements with an href. The article noted that rendering at scale requires more resources than simply downloading HTML. This describes that tool at that time and should not be treated as a current rule for all tools.
References
- 瞭解 JavaScript 搜尋引擎最佳化 (SEO) 基礎知識 | Google 搜尋中心 | Documentation | Google for Developersdevelopers.google.com — Source used in the article above.
- Google 的搜尋引擎最佳化連結最佳做法 | Google 搜尋中心 | Documentation | Google for Developersdevelopers.google.com — Source used in the article above.
- JavaScript SEO 完整指南,打造對搜尋引擎友善的網站www.awoo.ai · 2025-06-13T09:26:47+00:00 — Discusses: How can infinite-scroll pages make links easier to discover?
- How Ahrefs Counts Links and Domainsahrefs.com · 2021-01-12T16:00:44+00:00 — Discusses: Do SEO tools also count links inserted by JavaScript?
- How can I create links in javascript that are crawlable by search engines?webmasters.stackexchange.com — Source used in the article above.



