How to use the juice.juiceDocument function in juice

To help you get started, we’ve selected a few juice examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github neurosnap / scopeify-html / perf.js View on Github external
fixtures.forEach(fname => {
  const html = fs.readFileSync(`./fixtures/${fname}`);
  const htmlStr = html.toString();

  console.log('---');

  const scopeifyId = `scopeify-html ${fname}`;
  const doc = jsdom(html);
  console.time(scopeifyId);
  scopeifyHtml().sync(doc);
  console.timeEnd(scopeifyId);

  const juiceId = `juice ${fname}`;
  const $ = cheerio.load(htmlStr);
  console.time(juiceId);
  juice.juiceDocument($);
  console.timeEnd(juiceId);

  console.log('---');
});
github dial-once / node-dom-extractor / src / dom-extractor.js View on Github external
function cssCallback($, options, callback) {
  try {
    if (options.removeLinks) {
      removeLinks($);
    }
    $('body').html($(options.selector) || '');
    $('head').append(`<style>${options.extraCss}</style>`);
    const cacheKey = `${options.data}#${options.selector}#css${options.inlineCss}#innerText${options.innerText}`;
    nodeCache.set(cacheKey, juice.juiceDocument($, {
      extraCss: options.extraCss || ''
    })('body').html());
    callback(nodeCache.get(cacheKey));
  } catch (e) {
    callback();
  }
}
github SparkPost / heml / packages / heml-inline / src / index.js View on Github external
function inline ($, options = {}) {
  const { juice: juiceOptions = {} } = options

  juice.juiceDocument($, {
    ...juiceOptions
  })

  inlineMargins($)
  preferMaxWidth($, '[class$="__ie"]')
  fixWidthsFor($, 'img, .block__table__ie, .column')
  removeProcessingIds($)

  return $
}