GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Inlined CSS breaks when a stylesheet starts with a BOM · Issue #110 · clay/amphora-html

Inlined CSS breaks when a stylesheet starts with a BOM #110

New issue
Copy link
New issue
Copy link
Open
Open
Inlined CSS breaks when a stylesheet starts with a BOM#110
Copy link

Description

@macgyver
macgyver
opened on Oct 23, 2026
Issue body actions

combineFileContents() in lib/media.js reads each CSS file and joins them with fileContents.join('') into one <style> tag. If a file starts with a UTF-8 BOM (U+FEFF), the BOM lands in the middle of the combined CSS, attached to the next selector:

…}\uFEFF.article{--theme-color:var(--theme-color-light)}…

Browsers read \uFEFF.article as a different selector that matches nothing, so the first rule of every BOM-prefixed file after the first is silently dropped.

Why this happens:
We encountered this issue because we use sass to pre-compile our css files before handing them off to clay, since each component stylesheet is rendered individually and saved as a separate file, the sass compiler correctly adds a BOM to the top of the file when it needs to indicate that the contents are utf-8 (not plain ascii) and it was instructed to minify the contents (@charset "UTF-8"; would be used when the files were not minified)

  • Dart Sass adds a BOM to compressed output whenever the stylesheet contains non-ASCII characters (its charset option defaults to true).
  • PostCSS used to remove that BOM, but since 8.5.24 it keeps it (postcss#2119). In that PR, the PostCSS maintainer says removing BOMs when concatenating is the inlining tool's job.

Repro: inline two component stylesheets where the second starts with \uFEFF and its first rule sets a visible property. The page won't show that property.

Suggested fix: strip a leading BOM from each file before joining, e.g. in getContentsOfFiles:

contents.replace(/^\uFEFF/, '')

A BOM only means something at the very start of a standalone file, so removing it before inlining is always safe.

Workaround: compile with Sass charset: false.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402775 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.