You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

extract-css-core

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

extract-css-core

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

2.1.0
Source
npmnpm
Version published
Weekly downloads
1.6K
13.77%
Maintainers
1
Weekly downloads
 
Created
Source

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

Usage

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

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

Installation

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

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 👍, but not for pages with CSS-in-JS styling and inline styles 👎.

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-in-JS styling. Lastly, a plain old document.querySelectorAll('[style]') finds all inline styling.

API

extractCss(url, [options])

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

Options

Type: Object

Default: {}

waitUntil

Type: String

Default: networkidle0

Can be any value as provided by the Puppeteer docs.

  • Wallace CLI - Pretty CSS analytics in your terminal
  • get-css - The original get-css from CSSStats

Keywords

extract

FAQs

Package last updated on 09 Mar 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts