# Allow required CSS/JS resources

- Check 03.04 · Crawling · Critical
- Source: https://checklist-seo-geo.com/en/crawling/allow-required-css-js-resources
- Find the CSS, JavaScript and API files blocked by robots.txt that stop Google and Bing from rendering your pages, then fix the rules for your CMS.
- Updated on 2026-11-25
- Licence: CC BY 4.0. Credit “Checklist SEO & GEO” with a link to https://checklist-seo-geo.com/en/crawling/allow-required-css-js-resources.
- Plugin checklist-seo-geo: 1.3.1 · https://github.com/maximegaul/checklist-seo-geo

## In short

Google and Bing do not just read the HTML: they display the page in a headless browser, with its stylesheets, its scripts and the data those scripts fetch. If robots.txt disallows one of these files, the search engine sees an incomplete page, sometimes an empty one. This check consists of listing the resources your templates need, verifying that none is blocked, and fixing overly broad rules. Expected result: URL Inspection reports no resource blocked by robots.txt on your main templates.

## Why it matters

Googlebot queues every page that returns `200` for rendering, then runs its JavaScript with a recent version of Chromium. Its documentation is explicit: Google Search does not run JavaScript from blocked files. When a resource is disallowed, the search engine does not download it, and the rendered page differs from the one your visitors see:

- **Blocked CSS**: Google does not see the real layout. It may misjudge mobile-friendliness, where the main content sits or hidden elements.
- **Blocked JavaScript**: everything this script displays (product listings, menus, reviews, content loaded later) is missing from the render, and therefore from the index.
- **Blocked API**: a site whose content arrives through `fetch()` from `/api/` or `/wp-json/` stays empty for the search engine if that path is disallowed, even if the script is allowed.

Google has said so since 2014: blocking CSS or JavaScript directly harms how its algorithms render and index content. Bing gives the same instruction: let its crawlers access the CSS, scripts and images needed to load each page.

On the GEO side, the effect is partly different. Most generative engine crawlers (OAI-SearchBot, PerplexityBot, Claude-SearchBot) mainly read the initial HTML and run little or no JavaScript: allowing your scripts does not help them, the content has to be in the HTML (see [inspect the initial HTML](https://checklist-seo-geo.com/en/javascript-html-rendering/inspect-initial-html)). AI Overviews and Copilot, on the other hand, rely on the Google and Bing indexes, built from the render.

Not everything has to be opened. Google accepts that unimportant resources (analytics, ads, third-party widgets) be blocked if the page can still be understood without them.

## What it improves

- **Rendering and indexing**: Google and Bing index the content visitors see, including what JavaScript displays.
- **Mobile assessment**: the real layout is taken into account.
- **Structured data injected by script**: it becomes readable at render time.
- **Google and Microsoft AI answers**: indirect effect, through a more complete index. No effect on AI crawlers that do not render JavaScript.
- **Rankings**: indirect but real effect when main content depends on a blocked resource.

## How to check

**1. In Google Search Console**, on one page per template: [URL Inspection](https://search.google.com/search-console?action=inspect), “Test live URL”, “View tested page”, then the “More info” tab. The page resources list shows those that could not be loaded and why. Only the “Blocked by robots.txt” lines concern this check; other one-off failures are common and harmless. The screenshot in the same panel shows the page as Google renders it.

**2. Without access to Search Console**, Google's Rich Results Test shows the same resources panel for any public URL.

**3. From the command line**, on a typical page. Extract the CSS and JavaScript it calls:

```bash
SITE=https://example.com
curl -s "$SITE/" \
  | grep -o -E "(src|href)=[\"'][^\"']+\.(css|js|mjs)(\?[^\"']*)?[\"']" \
  | sed -E "s/^(src|href)=[\"']//; s/[\"']$//; s/&#038;/\&/g; s/&amp;/\&/g" \
  | sed -E "s#^//#https://#; s#^/#$SITE/#" \
  | sort -u > ressources.txt

grep "^$SITE/" ressources.txt > internes.txt
grep -v "^$SITE/" ressources.txt | cut -d/ -f1-3 | sort -u
```

The last command lists the other hosts called (CDN, static file subdomain): each one has its own robots.txt, to be read as well. Then test the internal resources with the `robots_check.py` script presented in [Allow Googlebot on strategic pages](https://checklist-seo-geo.com/en/crawling/allow-googlebot-strategic-pages):

```bash
curl -s "$SITE/robots.txt" -o robots.txt
python3 robots_check.py Googlebot robots.txt internes.txt | grep "BLOCKED"
python3 robots_check.py bingbot robots.txt internes.txt | grep "BLOCKED"
```

No output is the expected result. This extraction only sees the files referenced in the HTML: scripts loaded by other scripts and API calls show up in the Network tab of the browser's developer tools. Export the list and test it the same way.

## How to implement

### Before you start

The rules that block resources by accident are almost always the same:

| Rule | What it blocks | Fix |
| --- | --- | --- |
| `Disallow: /*?` | every resource versioned by a parameter (`style.css?ver=6.8`, `app.js?v=3`) | add `Allow: /*.css` and `Allow: /*.js`, which are longer and therefore take priority |
| `Disallow: /*.js$` or `Disallow: /*.css$` | all JavaScript or all CSS | delete |
| `Disallow: /assets/`, `/static/`, `/build/`, `/dist/` | the folder of compiled files | delete |
| `Disallow: /wp-content/`, `/wp-includes/`, `/modules/`, `/plugins/`, `/components/` | theme and extension files | delete, or add `Allow` rules by file extension |
| `Disallow: /api/`, `/wp-json/` | the data displayed by JavaScript | allow the endpoints read by public pages |

A fix template for when a folder must stay disallowed except for its rendering files, modeled on Drupal's default file:

```txt
User-agent: *
Allow: /modules/*.css
Allow: /modules/*.js
Allow: /modules/*.svg
Allow: /modules/*.webp
Disallow: /modules/

Sitemap: https://example.com/sitemap.xml
```

`Allow: /modules/*.css` (14 characters) is longer than `Disallow: /modules/` (9 characters): it wins for CSS files, with or without a version parameter. The order of the lines does not matter to Google.

> **Tip:** do not create a `User-agent: Googlebot` group to open resources to it. It would stop reading the `*` group and all your other disallow rules. Fix the general group.

What you can leave blocked without harm: analytics scripts, ads, A/B tests, chat widgets, provided the main content does not depend on them.

### Apache

Versions: Apache 2.4.

robots.txt is edited at the root of the site. Also check that the server does not refuse resources to crawlers in some other way, for example hotlink protection that returns `403` when the `Referer` header is missing, which is the case for rendering requests:

```bash
grep -r -n -i -E "HTTP_REFERER|hotlink" /var/www/example/public/.htaccess /etc/apache2/sites-enabled/
curl -s -o /dev/null -w "%{http_code}\n" -A "Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)" https://example.com/assets/app.css
```

If such a rule exists, allow requests without a `Referer` (`RewriteCond %{HTTP_REFERER} !^$`) or limit it to heavy images.

### Nginx

Versions: Nginx 1.18 and later.

Run the same check for `valid_referers` and the `location` blocks that return `403` on static folders:

```bash
grep -r -n -i -E "valid_referers|invalid_referer|location .*(assets|static|build)" /etc/nginx/
```

With `valid_referers`, add the `none` value to accept requests without a `Referer`, then run `sudo nginx -t && sudo systemctl reload nginx`.

### Cloudflare

Versions: Cloudflare dashboard, all plans, November 2026.

Two Cloudflare-specific points:

- **The `/cdn-cgi/` path**: Cloudflare recommends disallowing it in robots.txt (`Disallow: /cdn-cgi/`), with an `Allow: /cdn-cgi/image/` exception if you use its image resizing. If Rocket Loader is on, the script that loads all your other scripts is served under `/cdn-cgi/scripts/`: check in URL Inspection that it does not show up as blocked, and otherwise add `Allow: /cdn-cgi/scripts/`.
- **A proxied static file subdomain** (`static.example.com`) serves its own robots.txt. Check it: a `Disallow: /` added “because it is not content” blocks all rendering.

Firewall rules must not challenge resource requests from verified bots: add `and not cf.client.bot` to rules that target `/assets/` or `/api/`.

### AWS

Versions: Amazon S3 and CloudFront, AWS CLI v2, November 2026.

A **CloudFront** distribution dedicated to static files, often in front of an **S3** bucket, is a host in its own right. If it uses its own domain name (`cdn.example.com`), upload a permissive robots.txt to it:

```bash
printf 'User-agent: *\nAllow: /\n' > robots-cdn.txt
aws s3 cp robots-cdn.txt s3://STATIC_BUCKET_NAME/robots.txt --content-type "text/plain; charset=utf-8"
aws cloudfront create-invalidation --distribution-id DISTRIBUTION_ID --paths "/robots.txt"
```

Without a file, the bucket may answer `403` to `/robots.txt` when public access is restricted at the origin: Google treats that status as having no restrictions, which works, but an explicit file removes any ambiguity.

### Shared hosting

Fix `robots.txt` at the web root. If you reused an old “optimized” robots.txt template, compare it with the table in the “Before you start” subsection: many still disallow plugin or theme folders.

### WordPress

Versions: WordPress 6.4 to 7.1; Yoast SEO 22 to 28, WP Rocket 3, Autoptimize 3, LiteSpeed Cache 6 and 7.

WordPress's virtual file only disallows `/wp-admin/` and leaves `admin-ajax.php` open: it blocks no rendering resource. Problems come from a physical file or a plugin:

- **`Disallow: /wp-includes/`, `/wp-content/plugins/` or `/wp-content/themes/`**: delete these lines. WordPress loads jQuery and core scripts from `/wp-includes/`, themes and plugins from `/wp-content/`.
- **`Disallow: /*?`**: WordPress adds `?ver=` to every stylesheet and script registered with `wp_enqueue_style` and `wp_enqueue_script`. This rule therefore blocks everything; add `Allow: /*.css` and `Allow: /*.js`.
- **`/wp-json/`**: Yoast SEO offers, in its crawl optimization options, to disallow this path. Leave it open if your theme, a page builder or a decoupled (headless) site reads content through the REST API.
- **File optimization**: plugins that combine CSS and JavaScript (WP Rocket, Autoptimize, LiteSpeed Cache) write their files to `/wp-content/cache/` or, for LiteSpeed Cache, `/wp-content/litespeed/`: these folders must not be disallowed.

### Shopify

Versions: Shopify admin, all plans, November 2026.

Theme files are served by Shopify's CDN on its own domains, with its own robots.txt: you have no control over it and they are crawlable. On your domain, do not reintroduce a disallow rule for theme or script folders in `robots.txt.liquid`.

### PrestaShop

Versions: PrestaShop 8 and 9 (up to 9.2).

The file generated by PrestaShop disallows the `/modules/` and `/js/` folders, but explicitly allows module CSS, JavaScript and images (`Allow: */modules/*.css`, `Allow: */modules/*.js`…) as well as `/js/jquery/`. Theme files, under `/themes/`, are not affected. Two checks:

- a module that loads a script from `/js/` outside `/js/jquery/` is blocked: spot it with URL Inspection and add `Allow: /js/*.js` by hand;
- the `Allow` rules disappear if you replace the file with an external template: regenerate it from `Shop Parameters > Traffic & SEO` instead, then reapply your additions.

### Magento

Versions: Magento Open Source and Adobe Commerce 2.4.7 to 2.4.9.

Magento serves its compiled files from `/static/` (or `/pub/static/` depending on the web root) and media from `/media/`. No default rule disallows them; check in `Content > Design > Configuration`, custom instructions field, that an imported template does not do so.

### Drupal

Versions: Drupal 10 and 11.

The default robots.txt disallows `/core/` and `/profiles/` but allows their CSS, JavaScript and images with `Allow` rules on `*.css$` and `*.css?`; recent Drupal 11 versions add the WebP and AVIF formats. If you replaced the file with a shorter version, these exceptions may have disappeared: compare with the file shipped by Drupal. Composer updates rewrite this file, unless you have excluded it from scaffolding.

### Joomla

Versions: Joomla 4 to 6.

The `robots.txt.dist` file in Joomla 4 to 6 disallows, among others, `/components/`, `/modules/` and `/plugins/`. Core files and those of recent extensions are served from `/media/`, which stays open; an old extension that loads its CSS or JavaScript from `/components/` or `/modules/` is blocked. Spot it with URL Inspection and add the matching `Allow` rules.

### Laravel

Versions: Laravel 10 to 13, with Vite.

Vite publishes compiled files to `public/build/assets/`. Disallow neither `/build/` nor the API routes your public pages call to display content. If a rate-limiting middleware (`throttle`) protects these routes, a crawler that renders many pages may receive `429` responses: keep rate limiting for write routes.

### Next.js

Versions: Next.js 13 to 16; the file is called `proxy.ts` from Next.js 16 onward.

Never disallow `/_next/`: `/_next/static/` contains all of the application's JavaScript and CSS. The proxy (formerly middleware) runs by default on every request, static files included: a redirect to a login or language page can then block resources. Exclude them from its `matcher`. Same principle with Nuxt and `/_nuxt/`.

#### Next.js 16

The file is called `proxy.ts`, at the root of the project or in `src/`:

```ts
// proxy.ts
export const config = {
  matcher: ['/((?!api|_next/static|_next/image|favicon.ico|sitemap.xml|robots.txt).*)'],
}
```

#### Next.js 13 to 15

The same `matcher` goes in `middleware.ts`. This name is still accepted by Next.js 16 but deprecated there: rename it to `proxy.ts` when upgrading (`middleware-to-proxy` codemod).

```ts
// middleware.ts
export const config = {
  matcher: ['/((?!api|_next/static|_next/image|favicon.ico|sitemap.xml|robots.txt).*)'],
}
```

## Common mistakes

- **`Disallow: /*?` on a WordPress site**: every stylesheet and script carries `?ver=`, so everything is blocked.
- **Disallowing theme and plugin folders “for security”**: robots.txt protects nothing, and rendering is broken.
- **Forgetting the robots.txt of the static subdomain or the CDN**: a `Disallow: /` on `cdn.example.com` blocks every resource of `example.com`.
- **Blocking the API that supplies the content**: the script is allowed, but the rendered page stays empty.
- **Creating a `Googlebot` group to open resources**: it loses every other rule of the `*` group.
- **Panicking over “Other error”** in the resources list: Google does not always load everything during a live test. Only “Blocked by robots.txt” concerns this check.
- **Relying on rendering for AI crawlers**: most do not run JavaScript; the content must be in the HTML.

## Frequently asked questions

### Should CSS and JavaScript files be allowed in robots.txt?

Yes, allow the CSS and JavaScript files your pages need to display. Google and Bing render pages like a browser: a blocked file is not downloaded, and the content or layout that depends on it is missing from the render, and therefore from the index. You can leave blocked the scripts that do not matter for the content, such as analytics or ads.

### How do I know whether Google cannot load some resources on my page?

Open URL Inspection in Search Console, run the live test, then view the tested page and its additional information: the resources list shows those that could not be loaded and why. The “Blocked by robots.txt” lines need fixing. Without access to Search Console, the Rich Results Test shows the same panel for any public URL.

### Do AI crawlers need access to my JavaScript files?

Most generative engine crawlers, such as OAI-SearchBot, PerplexityBot or Claude-SearchBot, mainly read the initial HTML and run little or no JavaScript. Allowing your scripts therefore does little for them: important content must be in the HTML sent by the server. AI Overviews and Copilot, however, rely on the Google and Bing indexes, which are built from the render.

### Why can blocking /wp-json/ hurt SEO?

Blocking /wp-json/ hurts SEO when the theme, a page builder or a decoupled site reads content through the WordPress REST API to display it. Google runs the script, but cannot fetch the disallowed data, and the rendered page stays incomplete. If your site never calls this API from public pages, disallowing it has no effect on rendering.

## Resources

- [Google: Understand JavaScript SEO basics](https://developers.google.com/search/docs/crawling-indexing/javascript/javascript-seo-basics)
- [Google: Updating our technical Webmaster Guidelines on CSS and JavaScript (2014)](https://developers.google.com/search/blog/2014/10/updating-our-technical-webmaster)
- [Google: URL Inspection tool](https://support.google.com/webmasters/answer/9012289)
- [Google: Introduction to robots.txt and blocking resources](https://developers.google.com/search/docs/crawling-indexing/robots/intro)
- [Cloudflare: the /cdn-cgi/ endpoint and robots.txt](https://developers.cloudflare.com/fundamentals/reference/cdn-cgi-endpoint/)
- [Next.js: proxy file convention](https://nextjs.org/docs/app/api-reference/file-conventions/proxy)

Next steps: [Compare initial HTML and rendered DOM](https://checklist-seo-geo.com/en/javascript-html-rendering/compare-initial-html-rendered-dom), [Test rendering in Search Console](https://checklist-seo-geo.com/en/javascript-html-rendering/test-rendering-search-console) and [Declare sitemaps in robots.txt](https://checklist-seo-geo.com/en/crawling/declare-sitemaps-robotstxt).
