A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://developers.google.com/search/docs/guides/fix-search-javascript below:

Fix Search-Related JavaScript Problems | Google Search Central | Documentation

Skip to main content

Stay organized with collections Save and categorize content based on your preferences.

This guide helps you identify and fix JavaScript issues that may be blocking your page, or specific content on JavaScript powered pages, from showing up in Google Search. While Google Search does run JavaScript, there are some differences and limitations that you need to account for when designing your pages and applications to accommodate how crawlers access and render your content. Our guide on JavaScript SEO basics has more information on how you can optimize your JavaScript site for Google Search.

Googlebot is designed to be a good citizen of the web. Crawling is its main priority, while making sure it doesn't degrade the experience of users visiting the site. Googlebot and its Web Rendering Service (WRS) component continuously analyze and identify resources that don't contribute to essential page content and may not fetch such resources. For example, reporting and error requests that don't contribute to essential page content, and other similar types of requests are unused or unnecessary to extract essential page content. Client-side analytics may not provide a full or accurate representation of Googlebot and WRS activity on your site. Use the crawl stats report in Google Search Console to monitor Googlebot and WRS activity and feedback on your site.

If you suspect that JavaScript issues might be blocking your page, or specific content on JavaScript powered pages, from showing up in Google Search, follow these steps. If you're not sure if JavaScript is the main cause, follow our general debugging guide to determine the specific issue.

  1. To test how Google crawls and renders a URL, use the Rich Results Test or the URL Inspection Tool in Search Console. You can see loaded resources, JavaScript console output and exceptions, rendered DOM, and more information.

    Optionally, we also recommend collecting and auditing JavaScript errors encountered by users, including Googlebot, on your site to identify potential issues that may affect how content is rendered. Here's an example that shows how to log JavaScript errors that are logged in the global onerror handler. Note that some types of JavaScript errors, such as a parse error, cannot be logged with this method.

    window.addEventListener('error', function(e) {
        var errorText = [
            e.message,
            'URL: ' + e.filename,
            'Line: ' + e.lineno + ', Column: ' + e.colno,
            'Stack: ' + (e.error && e.error.stack || '(no stack trace)')
        ].join('\n');
    
        // Example: log errors as visual output into the host page.
        // Note: you probably don't want to show such errors to users, or
        //       have the errors get indexed by Googlebot; however, it may
        //       be a useful feature while actively debugging the page.
        var DOM_ID = 'rendering-debug-pre';
        if (!document.getElementById(DOM_ID)) {
            var log = document.createElement('pre');
            log.id = DOM_ID;
            log.style.whiteSpace = 'pre-wrap';
            log.textContent = errorText;
            if (!document.body) document.body = document.createElement('body');
            document.body.insertBefore(log, document.body.firstChild);
        } else {
            document.getElementById(DOM_ID).textContent += '\n\n' + errorText;
        }
    
        // Example: log the error to remote service.
        // Note: you can log errors to a remote service, to understand
        //       and monitor the types of errors encountered by regular users,
        //       Googlebot, and other crawlers.
        var client = new XMLHttpRequest();
        client.open('POST', 'https://example.com/logError');
        client.setRequestHeader('Content-Type', 'text/plain;charset=UTF-8');
        client.send(errorText);
    
    });
  2. Make sure to prevent soft 404 errors. In a single-page application (SPA), this can be especially difficult. To prevent error pages from being indexed, you can use one or both of the following strategies:

    When a SPA is using client-side JavaScript to handle errors they often report a 200 HTTP status code instead of the appropriate status code. This can lead to error pages being indexed and possibly shown in search results.

  3. Expect Googlebot to decline user permission requests.
    Features that require user permission don't make sense for Googlebot, or for all users. For example, if you make the Camera API required, Googlebot can't provide a camera to you. Instead, provide a way for users to access your content without being forced to allow camera access.
  4. Don't use URL fragments to load different content.
    A SPA may use URL fragments (for example https://example.com/#/products) for loading different views. The AJAX-crawling scheme has been deprecated since 2015, so you can't rely on URL fragments to work with Googlebot. We recommend using the History API to load different content based on the URL in a SPA.
  5. Don't rely on data persistence to serve content.
    WRS loads each URL (refer to How Google Search Works for an overview of how Google discovers content), following server and client redirects, same as a regular browser. However, WRS does not retain state across page loads:
  6. Use content fingerprinting to avoid caching issues with Googlebot.
    Googlebot caches aggressively in order to reduce network requests and resource usage. WRS may ignore caching headers. This may lead WRS to use outdated JavaScript or CSS resources. Content fingerprinting avoids this problem by making a fingerprint of the content part of the filename, like main.2bb85551.js. The fingerprint depends on the content of the file, so updates generate a different filename every time. Check out the web.dev guide on long-lived caching strategies to learn more.
  7. Ensure that your application uses feature detection for all critical APIs that it needs and provide a fallback behavior or polyfill where applicable.
    Some web features may not yet be adopted by all user agents and some may intentionally disable certain features. For example, if you use WebGL to render photo effects in the browser, feature detection shows that Googlebot doesn't support WebGL. To fix this, you could skip the photo effect or decide to use server-side rendering to prerender the photo effects, which makes your content accessible to everyone, including Googlebot.
  8. Make sure your content works with HTTP connections.
    Googlebot uses HTTP requests to retrieve content from your server. It does not support other types of connections, such as WebSockets or WebRTC connections. To avoid problems with such connections, make sure to provide an HTTP fallback to retrieve content and use robust error handling and feature detection.
  9. Make sure your web components render as expected. Use the Rich Results Test or the URL Inspection Tool to check if the rendered HTML has all content you expect.
    WRS flattens the light DOM and shadow DOM. If the web components you use aren't using <slot> mechanism for light DOM content, consult the documentation of the web component for further information or use another web component instead. For more information, see best practices for web components.
  10. After you fix the items in this checklist, test your page with the Rich Results Test or the URL inspection tool in Search Console again.

    If you fixed the issue, a green check mark appears and no errors display. If you still see errors, post in the Search Central help community.

Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2025-03-06 UTC.

[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-03-06 UTC."],[[["This guide helps you identify and fix JavaScript issues that may be preventing your website content from appearing correctly in Google Search."],["Use the Rich Results Test or the URL Inspection Tool to see how Googlebot crawls and renders your web pages, including loaded resources, JavaScript errors, and the rendered DOM."],["Ensure your single-page application handles soft 404 errors correctly by redirecting to a 404 page or using the noindex meta tag for error pages."],["Avoid using URL fragments for loading content and rely on the History API instead, and ensure your web components render as expected by using the `\u003cslot\u003e` mechanism for light DOM content."],["Googlebot has limitations, such as declining permission requests and not supporting data persistence or connections like WebSockets and WebRTC, so design your content accordingly with fallbacks."]]],["To resolve JavaScript-related search issues, first, test how Google crawls and renders your URLs using the Rich Results Test or URL Inspection Tool. Collect and audit JavaScript errors. Prevent soft 404 errors by redirecting or adding a \"noindex\" meta tag. Avoid relying on user permission requests, URL fragments, or data persistence. Employ content fingerprinting to avoid caching issues. Use feature detection for critical APIs, ensure HTTP connection compatibility, and verify web component rendering. Finally, retest your page after fixes.\n"]]


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4