extract-css-core

2.0.0-beta.1 • Public • Published

extract-css-core

Extract all CSS from a given url, both server side and client side rendered.

NPM Version Weekly downloads Build Status Known Vulnerabilities Dependencies Status Dependencies Status XO code style Project: Wallace

Problem, solution and shortcomings

Problem

Existing packages like get-css look at a server-generated piece of HTML and get all the <link> and <style> tags from it. This works fine for 100% server rendered pages, and pages with CSS-in-JS styling.

Solution

This module uses an instance of Chromium to render a page. This has the benefit that most of the styles can be rendered, even when generated by JavaScript. The Puppeteer CSSCoverage API is the power behind finding most of the CSS. Additionally, the document.styleSheets API is used to get CSS-inJS styling.

Installation

npm install extract-css-core
# or
yarn add extract-css-core

Usage

const extractCss = require('extract-css-core')

const css = await extractCss('http://www.projectwallace.com')

API

extractCss(url, [options])

Extract CSS from a page. Returns a Promise that contains the CSS as a single String.

Options

Type: Object

Default: null

waitUntil

Type: String

Default: networkidle2

Can be any value as provided by the Puppeteer docs.

Related

Package Sidebar

Install

npm i extract-css-core@2.0.0-beta.1

Version

2.0.0-beta.1

License

MIT

Unpacked Size

6.7 kB

Total Files

4

Last publish

Collaborators

  • bartveneman