Home > Article > Web Front-end > Can search engines index JavaScript?
JavaScript provides users with an intuitive, dynamic and interactive online experience. When scraping traditional HTML pages, everything is simple and the process is fast. Googlebot may access it simultaneously after downloading the HTML file and extracting a link to the source code. Once the CSS file is downloaded, the page will be indexed by Google's indexer, which also receives all downloaded resources.
Things get challenging when crawling websites that primarily use JavaScript. Googlebot downloads the HTML file.
Googlebot cannot see links in the source code because they are only inserted after the JavaScript runs.
Next, download the CSS and JS files. Googlebot must use the Google Web Rendering Service to parse, build, and run JavaScript.
WRS retrieves data from a database or other API.
Indexer can index materials. Googlebot can then add the newly found link to its queue for further crawling.
This involves web page rendering. The process of converting HTML, CSS, and JavaScript code into the interactive web page that visitors expect to see when they click a link is called rendering the web page. Every page of the website is created with the user in mind.
Parsing, building, and executing JavaScript files takes a lot of time, both for users and Google. Google often cannot index the content of pages that contain large amounts of JavaScript until the site is fully generated.
Not everything that is slower happens during the rendering process. It also describes ways to find new connections. Google often cannot find links on JavaScript-rich website pages before generating the page. JavaScript is a computer language that must be built before it can be used; any syntax that is incompatible with a specific version of JavaScript will cause the build to fail.
The latest Chrome version is the basis for Googlebot. This indicates that Googlebot is using the latest version of the browser to render the site. Googlebot browses websites the same way a human would use a browser. However, Googlebot is not a standard Chrome browser. Googlebot denies the user authorization request (i.e. Googlebot will deny the video autoplay request). Cross page loading, Cookies, local storage and session storage will be deleted. If your content relies on cookies or other locally saved information, Google will not index your content. Googlebot may decide not to download all resources, but browsers always do.
Google considers canonical tag changes made using JS to be unreliable. Therefore, make sure your canonical URL is in HTML format and not JS format. While it's possible that Google has fixed this problem, you shouldn't risk SEO until you know for sure.
Google knows a lot about JavaScript. However, JavaScript does require more work than plain HTML as crawlers try to understand and rank the billions of websites around the world. It can sometimes suffer from this.
Google claims that Googlebot crawls websites using JavaScript in two stages. The crawler will inspect the HTML during the initial scan and use it to index the site. They'll come back later to display the necessary JavaScript. However, material tagged with HTML appears on websites produced using server-side rendering. Googlebot does not need to visit the site again to render the JavaScript on the page to properly index the content because the main content is already visible. This can greatly improve JavaScript SEO methods.
Due to the time difference between the first and second views of the site, content contained in JavaScript will not be indexed quickly. Therefore, these materials are not considered when determining initial rankings, and it may take some time for Google to notice changes and update its results.
Therefore, businesses employing JavaScript SEO should ensure that they include as much important material as possible in the HTML of their website. They should write important information so that crawlers can immediately understand it (if they want this information to count towards rankings).
The JavaScript will not be rendered until Googlebot views your site a second time. As a result, some websites mistakenly add tags, such as a "no index" tag, to the HTML loaded during Google's first scan of the site. This tag may prevent Googlebot from accessing the site again to execute JavaScript, causing the site to be indexed incorrectly.
JavaScript remains an important part of the Internet as businesses leverage it to mark up their pages and make their sites more attractive to visitors. But for many, it’s still important to understand how Googlebot and other crawlers interpret JavaScript and how it interacts with JavaScript SEO. JavaScript-based websites can now be used by crawlers and search engines with HTML-based websites can. However, developers are responsible for making their sites accessible and crawlable, and for understanding how SEO works for contemporary JavaScript sites.
The above is the detailed content of Can search engines index JavaScript?. For more information, please follow other related articles on the PHP Chinese website!