cheerio

cheerio (GitHub: MatthewMueller/cheerio, License: MIT) is a fast, flexible, and lean implementation of core jQuery written by Matthew Mueller and designed specifically for the server.

1
npm install cheerio

Features

  • Familiar syntax. cheerio implements a subset of core jQuery. cheerio removes all the DOM inconsistencies and browser cruft from the jQuery library, revealing its truly gorgeous API.
  • Blazingly fast. cheerio works with a very simple, consistent DOM model. As a result parsing, manipulating, and rendering are incredibly efficient. Preliminary end-to-end benchmarks suggest that cheerio is about 8x faster than JSDOM.
  • Insanely flexible. cheerio wraps around @FB55‘s htmlparser2 (GitHub: fb55/htmlparser2, License: MIT)cheerio can parse nearly any HTML or XML document.

Example

1
2
3
4
5
6
7
8
var cheerio = require('cheerio'),
    $ = cheerio.load('<h2 class="title">Hello world</h2>');
$('h2.title').text('Hello there!');
$('h2').addClass('welcome');
$.html();
//=> <h2 class="title welcome">Hello there!</h2>

Screencast Introduction

Are you using jQuery on the server side?

Post navigation

dat

Leave a comment

Leave a Reply

Your email address will not be published.