squirrelscan
GitHub

HTML document size: when a page is too big to crawl fully

A very large HTML document risks being read only in part. squirrel measures the response body and warns at 1MB, failing at 2MB by default.

What the HTML size limit is

Crawlers do not read an unlimited amount of markup. Google documents that Googlebot fetches up to 2 MB from any individual URL other than a PDF, response headers included, and stops there. The bytes past the cutoff are not fetched, not rendered and not indexed. Referenced resources such as stylesheets and scripts have their own separate per-URL counter and do not consume the document’s allowance.

Most pages are nowhere near it. A page gets there through inline base64 images, large blocks of inline CSS or JavaScript, or a serialised framework payload, and what falls off the end is whatever came last in the file.

squirrel’s default failure threshold is that same 2 MB, with a warning at 1 MB so a page is flagged before it starts losing content.

What squirrel checks

The rule runs on every crawled page. It measures the UTF-8 byte length of the response HTML and emits a check named html-size, plus a second one, html-parse, on a page whose markup could not be read in full (below):

  • Fail at or above error_bytes, 2 MB by default. Message: HTML is 2.4MB — exceeds Googlebot 2MB limit, content will be truncated, with the byte count as the value and the threshold as the expected value. Severity error, weight 5.
  • Warn at or above warn_bytes, 1 MB by default. Message: HTML is 1180KB — approaching Googlebot 2MB limit.
  • Pass otherwise. Message: HTML size OK: 84KB.

Both thresholds are configurable. The default failure threshold matches the 2 MB per-URL limit Google documents for Googlebot.

How to fix it

const catalogue = await fetch("/data/catalogue.json").then((r) => r.json());

Move large inline blobs out of the document and fetch them instead. A <script type="application/json"> block only holds inline data, so an external file has to be requested rather than referenced with src. Serialised state, base64 images, inline SVG sprites and inline CSS are the usual culprits. Paginate or lazy-load long lists rather than rendering ten thousand rows.

Keep the title, meta description, headings and main body near the top of the file. If anything is ever cut, it should be the parts that do not describe the page.

Rule IDcrawl/html-size
CategoryCrawlability
ScopePer-page
Severityerror
Weight5/10

Options

OptionTypeDefaultDescription
warn_bytesnumber1048576Byte size to trigger warning
error_bytesnumber2097152Byte size to trigger error (Googlebot truncation limit)

Configuration example

[rule_options."crawl/html-size"]
warn_bytes = 512000
error_bytes = 1048576

Enable / disable

Disable this rule

[rules]
disable = ["crawl/html-size"]

Disable all Crawlability rules

[rules]
disable = ["crawl/*"]

Enable only this rule

[rules]
enable = ["crawl/html-size"]

enable replaces the default ["*"], so this is the only rule selected. Leave disable out: a rule that matches any disable pattern is skipped even when enable names it. Only an enabled setting under a rule’s own [rule_options] table overrides both lists.

Crawlability findings ship in every audit next to the SEO, performance and agent experience rules. See The Screaming Frog alternative for agents for how an agent works through a report.

Glossary: Googlebot file size limit.

A page whose markup could not be read in full

The rule emits a second check, html-parse, when a page’s markup had to be degraded for the audit to read it. A class attribute of more than 20,000 tokens makes the HTML parser overflow its stack (from about 640,000 tokens, an attribute of a little over a megabyte), so the page is read again with that attribute cut to its first 20,000 tokens, and everything after it is read normally. Which attribute is cut is decided by the same tokenizer that parses the page, so only a class value the parse would read is touched, and nothing else on the page changes. A page that cannot be read at all is audited empty.

Either way the page gets a warning, html-parse, that says which. Its findings were made on what could be read: rules that match on class names (an overlay, a cookie banner, an interstitial) do not see the tokens past the 20,000th on a cut attribute, and an empty page reports the elements it never saw as missing. Shorten the class list (a real one has tens of tokens) and audit the page again. One page like this does not stop the audit: the other pages are audited and the report is written. A page that parses the first time is not changed.

The parser splits an HTML element’s class value on tab, line feed, form feed, carriage return and space only, so a no-break space stays inside a token as it does in a browser, and every rule and detector that reads a class list splits it on that same ASCII whitespace set. Two residuals remain: an <svg> element’s class is still split on every JavaScript whitespace character, and a CSS selector run through the selector engine (.a, [class~=a] in querySelector) still matches a class across a no-break space, because that engine tests the value against a JavaScript \s pattern.

References

Check your site

Run squirrel audit https://example.com and open the Crawlability section of the report. Every oversized page is listed with its exact byte count. Signed-out local audits need no account and cost nothing. Signed-in audits spend credits.

Type to search…

↑↓ navigate↵ openesc close