Repository navigation
Description
Summary. On a page that is correctly declared as UTF-8 (HTTP
Content-Type: text/html; charset=utf-8, <meta charset> fully inside the first 1024
bytes), squirrel warns UTF-8 charset declared but not at start of head when a viewport
meta precedes the charset meta. Placing the charset first is a defensible best practice
(Lighthouse recommends it too), but the same warning level is used for real encoding
problems, so correctly declared pages read as broken.
Data. 6,892 open findings on 28 of 84 sites (total). Live examples: delife.bg product
page (meta charset starts at byte 543), bmsc24.de (byte 988); both send the UTF-8 HTTP
header.
Repro.
<!doctype html><html lang="de"><head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta charset="utf-8">
<title>Charset placement</title>
</head><body>Grüße</body></html>Serve as UTF-8 with Content-Type: text/html; charset=utf-8 (same one-line server as
above). Control: swap the two meta elements, header unchanged.
squirrel audit http://127.0.0.1:8765/ --http --refresh -m 1 -f json -o out.json- Actual:
core/charsetstatuswarn,UTF-8 charset declared but not at start of head;
control page passes. - Expected: treat this page as correctly declared UTF-8 and report the placement as
advice, e.g.UTF-8 is declared correctly; consider placing the charset meta first in head (best practice), at a lower level than missing or conflicting declarations. A
meta declaration extending beyond byte 1024 stays an HTML-conformance issue
(WHATWG §4.2.5.4), even when the HTTP header decides the decoding.
Verified on 0.0.108 with the control page: viewport-first warns, control passes.
Acceptance Criteria
- A page declared as UTF-8 by header or
<meta charset>inside the first 1024 bytes, with the charset meta not first in head, reports placement advice, not an encoding problem. - The message says UTF-8 is declared correctly and suggests moving the charset meta first; its status is lower than the missing and conflicting-declaration cases.
- A charset meta that starts beyond byte 1024 is still reported as an HTML-conformance issue.
- Missing and conflicting charset declarations keep their current status.
- Tests cover viewport-first (advice), charset-first (pass), beyond 1024 bytes (still flagged) and header-only.
Activity
nc9 commentedon Oct 11, 2026
Thanks Denis. Confirmed:
core/charsetuses the samewarnfor "UTF-8 declared but not first in head" as for real declaration problems. Triaged as an enhancement (P3), size S, area rules. I added acceptance criteria. I agree with splitting placement advice from encoding problems, and with keeping a declaration beyond byte 1024 as a conformance issue.nc9 commentedon Oct 11, 2026
Reproduced on 0.0.108 with a local fixture. Viewport meta first, then
<meta charset="utf-8">, headertext/html; charset=utf-8:core/charset, checkcharset, statuswarn,UTF-8 charset declared but not at start of head. The control (charset meta first) passes.origin/main still has this:
packages/rules/src/core/charset.tsdecides by element position (first child of<head>, or right after<title>), not by byte offset.Two things that matter for the acceptance criteria, both checked on 0.0.108:
<head>but starts after a 2,000-byte comment passes.Content-Type: text/html; charset=iso-8859-1and<meta charset="utf-8">first passes as UTF-8, although the header decides the decoding.nc9 commentedon Oct 11, 2026
Scope note from the repro run: on current main the rule has no byte-offset check, and a header that conflicts with the meta charset (for example header iso-8859-1 and meta utf-8) passes. Criteria 3 and 4 above therefore need new behaviour, not just a message change, so this is closer to size M if both are kept. We can split them out if you prefer a smaller first fix.
fix(rules): meta-title whitespace, charset placement advice, tel (0) …
nc9 commentedon Oct 11, 2026
Update: the fix landed in pub#676 (#658 and #663 closed by it). Split for #659: met end to end are the placement advice (UTF-8 declared correctly but charset meta not first in head is now info advice, not a warning) and the 1024-byte check (a charset meta that does not end within the first 1024 bytes now warns). The header-declared UTF-8 pass and the header-vs-meta conflict warning work in the rule's unit tests but cannot fire in a real audit yet, because the crawler drops the Content-Type charset before rules see it. That is tracked in #674. Also note that info checks are not shown in the text, LLM or JSON reports today (#669), so the placement advice is score-neutral and only visible in the stored rule results until that lands. Leaving #659 open until #674 lands.
nc9 commentedon Oct 12, 2026
Release check 2026-10-12 (v0.0.109): the meta-charset placement advice shipped (pub#676, first tag v0.0.109). The header-declared case cannot be exercised in real audits because the crawler strips the Content-Type charset before rules see it (#674). Leaving open until #674 lands.
nc9 commentedon Oct 16, 2026
Verified on main 6b8406b:
packages/rules/tests/core-charset.test.ts23/23 (viewport-first advice is info, charset-first passes, beyond-1024 still warns, header-only passes in the unit test, missing/conflicting unchanged). The remaining gap, the header-declared case in a real audit, is fixed by pub#883 (#674): a real CLI audit before and after is in that PR. pub#883 closes this issue when it merges.fix(crawler): carry the Content-Type charset to rules so core/charset…