https://github.com/jlopezxs/express-inline-css
:mag: Express middleware to generate inline critical rendering CSS
https://github.com/jlopezxs/express-inline-css
critical-css express-inline-css express-middleware inline-styles
Last synced: 9 months ago
JSON representation
:mag: Express middleware to generate inline critical rendering CSS
- Host: GitHub
- URL: https://github.com/jlopezxs/express-inline-css
- Owner: jlopezxs
- License: mit
- Created: 2016-08-30T06:58:59.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2018-03-19T09:42:27.000Z (over 8 years ago)
- Last Synced: 2025-08-10T09:40:52.064Z (10 months ago)
- Topics: critical-css, express-inline-css, express-middleware, inline-styles
- Language: JavaScript
- Homepage:
- Size: 143 KB
- Stars: 5
- Watchers: 0
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# express-inline-css
> :zap: Express middleware to generate inline critical rendering CSS to improve render performance
[](https://travis-ci.org/jlopezxs/express-inline-css)
[](https://david-dm.org/jlopezxs/express-inline-css)
[](https://github.com/prettier/prettier)
[](http://commitizen.github.io/cz-cli/)
[](https://greenkeeper.io/)
## Installation
```sh
npm install --save express-inline-css
```
## Preview
```js
// Overriding the render method
import express from 'express';
import inlineCSS from 'express-inline-css';
const app = express();
app.use(inlineCSS({
override: true,
cssFilePath: '../client/public/css/style.css'
}));
app.get('/', (req, res) => {
res.render('index', {});
});
```
```js
// Using renderInlineCSS method
import express from 'express';
import inlineCSS from 'express-inline-css';
const app = express();
app.use(inlineCSS({
override: false,
cssFilePath: '../client/public/css/style.css'
}));
app.get('/', (req, res) => {
res.renderInlineCSS('index', {});
});
```
## Usage
inlineCSS({ cssFilePath, [override] });
where:
- `cssFilePath`: Path of the final css file where rules are taken out.
- `override` (optional): It brings you the possibility to override the method render or use renderInlineCSS method.
## License
MIT © [Jordi López](http://jlopezxs.github.io)