npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

drupalcritical

v1.1.1

Published

Critical CSS generator for Drupal

Downloads

17

Readme

Drupal Critical NPM version

Automated generation of Critical CSS for Drupal sites.

Note Drupal module will be released shortly, in the meantime you can use this by manually configuring which pages to proces (see example below)

Install

$ npm install --save drupalcritical

Usage

Example:

var critical = require('drupalcritical');

var settings = {
    inline: false,
    local: true,
    dest: 'dest/',
    extract: true,
    ignore: [
      '@font-face',
      /url\(/,
      /print/,
      /animation/g,
      /interpolation/g,
      /-webkit/g,
      /-moz/g,
      /-ms/g,
      /speak/g,
      /list-style-image/g,
      /list-style-type/g
    ],
    ignoreOptions: {
      matchSelectors: true,
      matchTypes: true,
      matchDeclarationProperties: true,
      matchDeclarationValues: true,
      matchMedia: true
    },
    dimensions: [{
      height: 200,
      width: 500
    }, {
      height: 900,
      width: 1200
    }]
  };


var pages = require('./critical.json');
critical.generate(settings, pages);

Critical.json

{
  "base": "http://www.example.com",
  "pages": [
    {
      "path": "/",
      "filename": "critical-home.css"
    },
    {
      "path": "/demo",
      "filename": "critical-demo.css"
    }
  ]
}

Options

note: Not all critical options are available, the list below includes all options

| Name | Type | Default | Description | | ---------------- | ------------------ | ------------- |------------- | | css | array | [] | An array of paths to css files, or an array of Vinyl file objects. | dest | string | ./ | Location of where to save the output of an operation (will be relative to base if no absolute path is set) |
| local | string | false | Use local (development) url to generate Critical CSS, if false it uses the given base |
| width | integer | 900 | Width of the target viewport | | height | integer | 1300 | Height of the target viewport | | dimensions | array | [] | An array of objects containing height and width. Takes precedence over width and height if set | minify | boolean | false | Enable minification of generated critical-path CSS | | extract | boolean | false | Remove the inlined styles from any stylesheets referenced in the HTML. It generates new references based on extracted content so it's safe to use for multiple HTML files referencing the same stylesheet. Use with caution. Removing the critical CSS per page results in a unique async loaded CSS file for every page. Meaning you can't rely on cache across multiple pages | | inlineImages | boolean | false | Inline images | assetPaths | array | [] | List of directories/urls where the inliner should start looking for assets | maxImageFileSize | integer | 10240| Sets a max file size (in bytes) for base64 inlined images | timeout | integer | 30000| Sets a maximum timeout for the operation | pathPrefix | string | / | Path to prepend CSS assets with. You must make this path absolute if you are going to be using critical in multiple target files in disparate directory depths. (eg. targeting both /index.html and /admin/index.html would require this path to start with / or it wouldn't work.) | include | array | [] | Force include CSS rules. See penthouse#usage. | ignore | array | [] | Ignore CSS rules. See filter-css for usage examples. | ignoreOptions | object | {} | Ignore options. See filter-css#options. | penthouse | object | {} | Configuration options for penthouse.

Changelog

v1.1.0 - 2017-11-24

  • renamed url to path
  • changed fixed filenaming to variable