How amrhalim/htmx-sync-css works
htmx-sync-css is a small browser extension that adds styles found in htmx response HTML. The page enables the extension; after an htmx request, the extension parses response style tags, skips previously seen IDs using an in-memory cache, and appends new styles to the document head. The runtime excerpts show parsing and DOM insertion; README documents the setup and response markup. External htmx event dispatch is represented from the extension registration contract.
Main entry points: index.ts sync-css extension · utils.ts Style tag parser · constants.ts Style tag matcher
Components 8
Other components
- Web page
- htmx runtime
- sync-css extension
src/index.ts - Style ID cache
src/index.ts - Style tag parser
src/utils.ts - Style tag matcher
src/constants.ts - Style injector
src/utils.ts - Document head
Connections 9
- Web page → htmx runtime: loads extension
README.md - sync-css extension → htmx runtime: registers extension
src/index.ts - htmx runtime → sync-css extension: dispatches event
src/index.ts - sync-css extension → Style tag parser: passes response
src/index.ts - sync-css extension → Style ID cache: provides cache
src/index.ts - Style tag parser → Style tag matcher: matches tags
src/utils.ts - Style tag parser → Style ID cache: checks IDs
src/utils.ts - sync-css extension → Style injector: passes new styles
src/index.ts - Style injector → Document head: appends styles
src/utils.ts