diff --git a/lib/cheerio.js b/lib/cheerio.js index 809e0ac78bc01a98675b43a771140e9f35cd4c71..23c565ad94ec15dd2e7f8e605b1bb849ef6769bd 100644 --- a/lib/cheerio.js +++ b/lib/cheerio.js @@ -3,7 +3,11 @@ /** * Module dependencies. */ -var cheerio = require('cheerio'); +// Ghost patch: cheerio's main entry eagerly loads parse5, undici and the whatwg +// encoding stack (~20MB RSS per process) none of which juice uses - the `xml` +// option below sets _useHtmlParser2, so parsing goes through htmlparser2 either +// way. cheerio/slim is that same htmlparser2 path without the unused baggage. +var cheerio = require('cheerio/slim'); var utils = require('./utils'); var cheerioLoad = function(html, options, encodeEntities) { diff --git a/lib/inline.js b/lib/inline.js index 083b8c58eb90184d0190cd0e3361a39638e4981b..492d0230dd2a3ee179359e3027f73cc7257023fe 100644 --- a/lib/inline.js +++ b/lib/inline.js @@ -117,7 +117,12 @@ module.exports = function makeJuiceClient(juiceClient) { ? decode(styleAttributeValue) : styleAttributeValue; var cssText = '* { ' + cssStyleAttributeValue + ' } '; - addProps(utils.parseCSS(cssText)[0][1], new utils.Selector('