Introducing Socket Firewall: Free, Proactive Protection for Your Software Supply Chain.Learn More
Socket
Book a DemoInstallSign in
Socket

@roots/bud-criticalcss

Package Overview
Dependencies
Maintainers
0
Versions
821
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@roots/bud-criticalcss

Adds critical.css support to Bud

latest
Source
npmnpm
Version
6.24.0
Version published
Weekly downloads
128
77.78%
Maintainers
0
Weekly downloads
 
Created
Source

bud.js

MIT License npm Follow Roots

@roots/bud-criticalcss

Adds critical.css support to Bud

Installation

Install @roots/bud-criticalcss to your project.

Yarn:

yarn add @roots/bud-criticalcss --dev

npm:

npm install @roots/bud-criticalcss --save-dev

Usage

  • Identify the markup to be used for critical css generation
  • Enable the extension

Identify source markup

You may use bud.critical.src to specify a URL or a path on disk to the markup that will be used to generate critical styles.

bud.critical.src(`http://example.test`);
bud.critical.src(bud.path("path/to/index.html"));

Or, you may use bud.critical.html to provide the markup directly.

bud.critical.html(`<html>...</html>`);

Enable the extension

You must explicitly call bud.critical.enable to enable the extension.

bud.critical.enable();

Example

export default async (bud) => {
  bud.critical.src(`http://example.test`).enable(bud.isProduction);
};

Configuration

bud.critical.src

Specify the source with a URL:

bud.critical.src(`http://example.test`);

Specify the source with a local filepath:

bud.critical.src(bud.path(`@src`, `template.html`));

bud.critical.html

Specify the markup directly

bud.critical.html(`<html>...</html>`);

bud.critical.width

Specify the width of the browser viewport

bud.critical.width(1920);

bud.critical.height

Specify the height of the browser viewport

bud.critical.height(1080);

bud.critical.extract

Extract critical css from its source file. Extraction is enabled by default but can be disabled by passing false.

bud.critical.extract(false);

bud.critical.ignore

Ignore certain CSS rules or declarations.

bud.critical.ignore({
  decl: [/^transition/],
  rule: [/^@font-face/],
});

bud.critical.enable

Enable or disable the extension.

It accepts an optional boolean argument. If no argument is provided, the extension will be enabled.

bud.critical.enable();

Contributing

Contributions are welcome from everyone.

We have contribution guidelines to help you get started.

License

@roots/bud-criticalcss is licensed under MIT.

Community

Keep track of development and community news.

Sponsors

bud.js is an open source project and completely free to use.

However, the amount of effort needed to maintain and develop new features and projects within the Roots ecosystem is not sustainable without proper financial backing. If you have the capability, please consider sponsoring Roots.

Carrot WordPress.com Worksite Safety Itineris

Keywords

bud

FAQs

Package last updated on 09 Dec 2024

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