All Projects → bezoerb → inline-critical

bezoerb / inline-critical

Licence: other
Inline critical path CSS and async load existing stylesheets

Programming Languages

HTML
75241 projects
javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to inline-critical

Premailer
Preflight for HTML email
Stars: ✭ 2,173 (+1950%)
Mutual labels:  inline
InlineCssParser
A Visual Studio Extension that helps to extract inline styles into a seperate css file.
Stars: ✭ 23 (-78.3%)
Mutual labels:  inline
Inlin-Craft
Plugin for inlining files in templates.
Stars: ✭ 64 (-39.62%)
Mutual labels:  inline
Juice
Juice inlines CSS stylesheets into your HTML source.
Stars: ✭ 2,683 (+2431.13%)
Mutual labels:  inline
temply
@temply_bot Telegram bot repository
Stars: ✭ 20 (-81.13%)
Mutual labels:  inline
vue-svg-inline-plugin
Vue plugin for inline replacement of SVG images with actual content of SVG files.
Stars: ✭ 30 (-71.7%)
Mutual labels:  inline
React Native See More Inline
Show a "read more", "see more", "read less", "see less" inline with your text in React Native
Stars: ✭ 141 (+33.02%)
Mutual labels:  inline
crittr
High performance critical css extraction with a great configuration abilities
Stars: ✭ 39 (-63.21%)
Mutual labels:  critical-path
atom-inline-blame
Atom package to display blame inline
Stars: ✭ 23 (-78.3%)
Mutual labels:  inline
asm-inline
Inline raw ASM instructions in Java
Stars: ✭ 23 (-78.3%)
Mutual labels:  inline
React Svg Inline
DEPRECATED, I recommend you the tool SVGR
Stars: ✭ 230 (+116.98%)
Mutual labels:  inline
react-cryptocoins
Сryptocurrencies icons as React components
Stars: ✭ 37 (-65.09%)
Mutual labels:  inline
js.metaret
lightweight mutual tail recursion optimization without trampoline
Stars: ✭ 16 (-84.91%)
Mutual labels:  inline
Datauri
Generate Data-URI scheme via terminal or node.js
Stars: ✭ 212 (+100%)
Mutual labels:  inline
nova-inline-morph-to
A Laravel Nova field for displaying morphTo relationship inline.
Stars: ✭ 32 (-69.81%)
Mutual labels:  inline
Node Inline Cpp
Inline C++ with Node.js
Stars: ✭ 172 (+62.26%)
Mutual labels:  inline
exe2hex
Inline file transfer using in-built Windows tools (DEBUG.exe or PowerShell).
Stars: ✭ 284 (+167.92%)
Mutual labels:  inline
compact str
A memory efficient string type that can store up to 24* bytes on the stack
Stars: ✭ 322 (+203.77%)
Mutual labels:  inline
node-inline-assets
Node API, CLI and Grunt Task for inlining external assets of HTML/CSS files
Stars: ✭ 18 (-83.02%)
Mutual labels:  inline
USERGE-X
USERGE-X. What the X ?
Stars: ✭ 133 (+25.47%)
Mutual labels:  inline

inline-critical

Inline critical-path css and load the existing stylesheets asynchronously. Existing link tags will also be wrapped in <noscript> so the users with javascript disabled will see the site rendered normally.

NPM version Build Status Dependency Status Download Coverage Status

Installation

This module is installed via npm:

$ npm install inline-critical

Example Usage

const inline = require('inline-critical');
const html = fs.readFileSync('test/fixtures/index.html', 'utf8');
const critical = fs.readFileSync('test/fixtures/critical.css', 'utf8');
const inlined = inline(html, critical);

Example Usage ignoring stylesheet per regex

const inline = require('inline-critical');
const html = fs.readFileSync('test/fixtures/index.html', 'utf8');
const critical = fs.readFileSync('test/fixtures/critical.css', 'utf8');

const inlined = inline(html, critical, {
  ignore: [/bootstrap/],
});

CLI

inline-critical works well with standard input. You can either pass in the html

cat index.html | inline-critical critical.css

or just flip things around

cat critical.css | inline-critical index.html

or pass in the file as an option

inline-critical critical.css index.html

without having to worry about the correct order

inline-critical index.html critical.css

Run inline-critical --help to see the list of options.

inline(html, styles, options?)

  • html is the HTML you want to use to inline your critical styles, or any other styles
  • styles are the styles you're looking to inline
  • options is an optional configuration object
    • strategy select the preload strategy
    • extract will remove the inlined styles from any stylesheets referenced in the HTML
    • basePath will be used when extracting styles to find the files references by href attributes
    • ignore ignore matching stylesheets when inlining.
    • selector defines the element used by loadCSS as a reference for inlining.
    • noscript specifies position of noscript fallback ('body' - end of body, 'head' - end of head, false - no noscript)
    • replaceStylesheets takes an array of stylesheet hrefs to replace the original links in the document. (Used by critical when you extract uncritical css to a target file)

PreloadStrategy

The mechanism to use for lazy-loading stylesheets. [JS] indicates that a strategy requires JavaScript (falls back to <noscript>).

  • default: Move stylesheet links to the end of the document and insert preload meta tags in their place.
  • "body": Move all external stylesheet links to the end of the document.
  • "media": Load stylesheets asynchronously by adding media="print" and swap to media="all" once loaded (https://www.filamentgroup.com/lab/load-css-simpler/). [JS]
  • "swap": Convert stylesheet links to preloads that swap to rel="stylesheet" once loaded. [JS]
  • "polyfill": Inject LoadCSS and use it to load stylesheets. [JS]

Adopted from critters

License

MIT

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].