How cheeriojs/cheerio works
Cheerio is a server- and browser-usable HTML/XML parsing and manipulation library. The principal workflow loads markup, parses it into a DOM-backed collection, supports jQuery-style selection, traversal, extraction, attributes, CSS, forms and structural edits, then renders HTML/XML or text. Loading also includes buffer decoding, streams and URL fetching in the batteries-included entry point. The graph follows documented behavior and source-index references; unsampled implementations are represented only where the tree or README supports their role.
Main entry points: cheerio.ts Cheerio collection · load-parse.ts Load factory · load.ts Selection and loading · index.ts Public entry points
Components 19
Entry and loading
- Public entry points
src/index.ts - Slim entry
src/slim.ts - Load and decode
src/index.ts - Parser options
src/options.ts
DOM core
- Load factory
src/load-parse.ts - Parser selection
src/parse.ts - Parse5 adapter
src/parsers/parse5-adapter.ts - Cheerio collection
src/cheerio.ts - Selection and loading
src/load.ts
Collection API
- Traversal
src/api/traversing.ts - Attributes and properties
src/api/attributes.ts - CSS methods
src/api/css.ts - Form methods
src/api/forms.ts - DOM manipulation
src/api/manipulation.ts - Data extraction
src/api/extract.ts
Rendering and output
- Static utilities
src/static.ts - HTML and XML rendering
src/load-parse.ts - Text output
src/static.ts
Other components
- Library caller
Connections 25
- Library caller → Public entry points: calls
Readme.md - Public entry points → Load and decode: exports
src/index.ts - Public entry points → Load factory: loads via
src/index.ts - Public entry points → Parser options: flattens
src/index.ts - Library caller → Slim entry: chooses
- Slim entry → Selection and loading: loads through
src/slim.ts - Load and decode → Load factory: passes markup
src/index.ts - Load factory → Parser selection: parses through
src/load-parse.ts - Load factory → Parse5 adapter: uses adapter
src/load-parse.ts - Load factory → Selection and loading: creates factory
src/load-parse.ts - Selection and loading → Parser options: flattens
src/load.ts - Selection and loading → Cheerio collection: instantiates
src/load.ts - Cheerio collection → Traversal: mixes in
src/cheerio.ts - Cheerio collection → Attributes and properties: mixes in
src/cheerio.ts - Cheerio collection → CSS methods: mixes in
src/cheerio.ts - Cheerio collection → Form methods: mixes in
src/cheerio.ts - Cheerio collection → DOM manipulation: mixes in
src/cheerio.ts - Cheerio collection → Data extraction: mixes in
src/cheerio.ts - DOM manipulation → Parser selection: parses inserted markup
src/api/manipulation.ts - Selection and loading → Static utilities: provides API
src/load.ts - Static utilities → Data extraction: delegates extraction
src/static.ts - Static utilities → HTML and XML rendering: renders markup
src/static.ts - Static utilities → Text output: returns text
src/static.ts - HTML and XML rendering → Parse5 adapter: serializes with
src/load-parse.ts - HTML and XML rendering → Parser selection: selects renderer
src/load-parse.ts