# JavaScript & SEO — SEO for Developers

Source: https://www.geekswithgeeks.com/en/seo-developers/seo-javascript-seo

> Understand how Google indexes JavaScript-heavy sites and when to use prerendering or SSR.

## The JavaScript problem

Google *can* render JavaScript, but it's not instant. If your content loads only after JS runs, there's a delay before indexing. The initial HTML must contain meaningful content; if it's empty, Google will see an empty page.

## Check what Google sees

Use the URL Inspection tool in Google Search Console to see how Google renders your page. This reveals if content is hidden behind JavaScript.

```html
<!-- PROBLEM: Empty HTML, content in JS -->
<html>
<body>
  <div id="app"></div>
  <script src="app.js"></script>
  <!-- Google might miss this if app.js renders slowly -->
</body>
</html>

<!-- BETTER: Meaningful initial HTML -->
<html>
<head>
  <title>My Blog Post</title>
  <meta name="description" content="...">
</head>
<body>
  <h1>My Blog Post Title</h1>
  <p>Post content visible without JS...</p>
  <div id="app"></div>
  <script src="app.js"></script>
  <!-- JS enhances but doesn't hide content -->
</body>
</html>
```
