

JavaScript Link Handling for SEO: Audit Discovery Paths
Author
Understanding How Search Engines Handle JavaScript Links
Google processes JavaScript pages through crawling, rendering, and indexing, and links may be found in the initial response or after rendering. The practical audit question is whether each important destination is exposed through a crawlable <a href> and remains present in rendered output.
Google’s JavaScript SEO guidance explains this processing model, while its crawlable-links guidance specifies the link markup Google can reliably parse. Treat raw-HTML and rendered-DOM presence as recorded observations; do not infer a universal discovery delay or ranking effect from either one alone.
Distinguishing Standard Links from Event-Only Navigation
Standard links are anchor elements (<a>) with an href attribute that points to a destination URL. These are crawlable because search engines can extract the URL directly from the HTML.
Event-only navigation, on the other hand, relies on JavaScript event listeners (such as onclick or addEventListener) that change the URL or trigger navigation without an href attribute.
For example, a <div> or <span> might have a click handler that calls window.location.href.
Google’s link best practices state that links are generally crawlable when they are anchor elements with href attributes; script-event pseudo-links and anchors without href are not reliably extracted.
To distinguish between the two, you can use a simple test: disable JavaScript in your browser and attempt to navigate the site. If clicking an element does not change the URL or load a new page, it is likely event-only navigation.
For a more systematic audit, you can use browser developer tools to inspect the DOM and identify elements with click handlers but no href.
This distinction is critical because event-only navigation can prevent search engines from discovering pages, leading to poor crawl coverage.
Testing Links in Raw HTML vs Rendered DOM
To audit link discovery, you need to compare the links present in the raw HTML response with those in the rendered DOM. This comparison reveals which links are immediately discoverable and which depend on JavaScript execution. Pair the result with the broader JavaScript rendering audit and use the website diagnosis service when crawl-path defects require code changes.
Here are concrete methods to perform this test:
- Using Chrome DevTools to Simulate Disabled JavaScript: Open Chrome DevTools, go to Settings, and under the "Debugger" section, enable "Disable JavaScript". Then, reload the page and view the page source (Ctrl+U or right-click > View Page Source). This shows the raw HTML as received from the server. Extract all anchor tags with
hrefattributes and note their URLs. Then, disable the JavaScript block and reload the page normally to see the rendered DOM. Use the Elements panel to inspect the DOM and extract links again. Compare the two lists to identify links that appear only in the rendered DOM.
- Using Google Search Console’s URL Inspection Tool: Run a live URL test as a Google-specific spot check for fetch and page-loading problems. The interface can change, so do not build the audit around assumed tab names. Google’s documentation warns that the live test does not cover every indexing condition. Use
curlplus a headless-browser snapshot for the repeatable raw-versus-rendered comparison.
- Using Command-Line Tools: For a more automated approach, you can use tools like
curlto fetch the raw HTML and a headless browser (e.g., Puppeteer) to render the page and extract the DOM. This allows you to script the comparison and record the results for multiple pages.
When comparing, pay attention to links that are missing from the raw HTML but present in the rendered DOM. These are the links that depend on JavaScript for discovery.
Also note any links that are present in the raw HTML but not in the rendered DOM, which might indicate that JavaScript removes or replaces them. Record your findings in an audit checklist to track the discovery method and test date.
Use the single link-discovery evidence record at the end of this guide. One shared schema keeps the initial audit and post-fix retest comparable.
Handling Infinite Scroll and Client-Side Routing
Infinite scroll and client-side routing are common JavaScript patterns that can obscure link discovery.
For SEO, the core issue is that crawlers may not execute JavaScript during the initial crawl, so links that are only injected after user interaction or scroll events may remain undiscovered.
Google can process links from rendered HTML, but blocked resources, script errors, and interaction-dependent loading can change the result. Keep critical navigation available through crawlable anchors in the initial response where the architecture permits, and verify both raw and rendered outputs.
Infinite Scroll: Provide Pagination or Load-More Links
Infinite scroll loads additional content as the user scrolls, but crawlers typically do not scroll. To make all content discoverable, implement a fallback mechanism such as traditional pagination (e.g., /page/2) or a "load more" button that uses a real anchor tag with an href pointing to the next page. Google’s link best practices emphasize that links must be crawlable, meaning they should be standard anchor elements with href attributes.
If you rely solely on infinite scroll, crawlers may only see the initial set of links, leaving deeper content orphaned.
When auditing, check whether the infinite scroll container includes a fallback link in the raw HTML. If not, the content is effectively hidden from crawlers that do not render JavaScript.
Even with rendering, Google may not trigger scroll events, so the fallback is essential.
Client-Side Routing: Use the History API and Unique URLs
Client-side routing (e.g., single-page applications) changes the URL without a full page reload. Google recommends using the History API (pushState) to update the URL, rather than using URL fragments (e.g., #/path), because fragments are not treated as separate URLs. Each route must have a unique, crawlable URL that returns the appropriate content in the raw HTML when possible.
If the content is only rendered client-side, ensure that the server returns a basic HTML shell with links to other routes, so crawlers can discover them.
During an audit, verify that each route has a unique URL and that the raw HTML contains at least the navigation links to other routes. If the raw HTML is empty or contains only a single div, the crawler may not discover internal links without rendering.
Use rel="canonical" and Sitemaps to Aid Discovery
For JavaScript-heavy sites, supplement link discovery with XML sitemaps. Sitemaps list all important URLs, helping crawlers find pages that might otherwise be missed.
Additionally, use rel="canonical" to consolidate duplicate content, especially when the same content is accessible via multiple URLs (e.g., with or without trailing slashes).
Google’s documentation on link best practices does not explicitly mention sitemaps, but the JavaScript SEO basics guide recommends using sitemaps to ensure all pages are known. This is a practical mitigation, not a guarantee of indexing.
When auditing, check that the sitemap includes all key pages and that each URL returns a 200 status. Also, verify that canonical tags point to the preferred version of the page.
Performing a Crawl Path Audit
A crawl path audit verifies that deep pages are discoverable by following links from the homepage, simulating how a crawler navigates. The goal is to identify any page that is not reachable via a chain of crawlable links.
This audit requires comparing raw HTML and rendered DOM to understand what a crawler sees at each stage.
Start from the Homepage and Simulate a Crawler
Begin by fetching the homepage’s raw HTML (view source or use a tool like curl) and extract all anchor tags with href attributes. These are the links that a crawler can discover without executing JavaScript.
Then, follow each link to the next page, repeating the process. This gives you the "raw crawl path." Next, use a headless browser or a tool like Screaming Frog with JavaScript rendering enabled to simulate a crawler that executes JavaScript.
Compare the links found in the rendered DOM to those in the raw HTML. Pages that appear only in the rendered DOM are dependent on JavaScript for discovery.
Google’s URL Inspection tool can show you the rendered HTML that Google sees, but it does not test every indexing condition. Use it to spot-check specific pages, but rely on your own crawler for a comprehensive audit.
Record How Each Page is Discovered
For each page, record whether it was discovered via raw HTML, rendered DOM, or both. This distinction is critical because raw HTML discovery is more reliable.
If a page is only discoverable after rendering, it may be subject to delayed indexing or not indexed at all if rendering fails.
Google’s JavaScript SEO basics state that Google uses both raw HTML and rendered HTML for crawling, but rendering is resource-intensive and not guaranteed. Therefore, pages that are only in the rendered DOM are at higher risk.
Use a spreadsheet to track each URL, the number of links in raw HTML, the number in rendered DOM, and any missing links. This data will form the basis of your audit evidence.
Use Crawler Tools with JavaScript Rendering
Tools like Screaming Frog can be configured to render JavaScript using Chrome. This allows you to see the rendered DOM and extract links that appear after script execution.
However, be aware that these tools may not perfectly replicate Google’s rendering behavior. Google’s rendering process is not publicly documented in full, so your audit is an approximation.
Use the tool’s settings to match common crawler behavior, such as waiting for network idle and executing all scripts.
When using such tools, document the tool version and configuration, as this affects the results. This documentation is part of your repeatable evidence.
Recording Repeatable Audit Evidence
To make your audit credible and repeatable, you must record evidence in a structured way. This allows you to compare results over time and verify that issues are fixed. The required artifact is an audit checklist with specific fields.
Save Snapshots of Raw HTML and Rendered HTML
For each page tested, save a copy of the raw HTML (as served to the crawler) and the rendered HTML (after JavaScript execution). This provides a permanent record of what was discoverable at the time of the audit.
Use a consistent naming convention, such as including the URL and date in the filename. These snapshots are essential for debugging and for proving that a link was missing.
Record Test Date, Tool Versions, and Configurations
Note the date of the audit, the crawler tool and version actually used, and the configuration settings (e.g., rendering enabled, user agent, viewport size).
This context is crucial because changes in tool versions or settings can affect the results. Without this information, the audit cannot be replicated accurately.
Create a Link Inventory with Discovery Status
Build a table that lists each page URL, the number of links found in the raw HTML, the number found in the rendered DOM, and any links that are missing from the raw HTML but present in the rendered DOM.
Also record the discovery method (raw, rendered, or both) and the test date. This inventory helps you prioritize fixes: pages with many missing links in raw HTML are the highest priority.
Below is a template for the audit checklist. Use one row per page, and fill in the fields during your audit.
| Page URL | Number of links in raw HTML | Number of links in rendered DOM | Links present in rendered DOM but missing from raw HTML | Discovery method | Test date |
|---|---|---|---|---|---|
| [Enter URL] | [Enter count] | [Enter count] | [List missing links or ‘None’] | [Raw / Rendered / Both] | [YYYY-MM-DD] |
This checklist is not a one-time exercise. Run it periodically, especially after any changes to the site’s JavaScript or navigation. By recording evidence consistently, you can track improvements and ensure that all important pages remain discoverable.
Remember that the evidence you collect is specific to your test environment and does not guarantee how Google will treat your pages.
Use the checklist to identify potential issues, but always verify with Google Search Console’s URL Inspection tool for individual pages.
Comments (0)
No comments yet. Be the first!