Security News
PyPI Now Supports iOS and Android Wheels for Mobile Python Development
PyPI now supports iOS and Android wheels, making it easier for Python developers to distribute mobile packages.
iodigital-criticalcss
Advanced tools
This node module makes it possible to generate critical css bundles from different pages in different viewports. It is based on GitHub - addyosmani/critical: Extract & Inline Critical-path CSS in HTML pages
npm install iodigital-criticalcss
First add a configuration file in the root of your project , named: criticalcss.config.json
.
This configuration should contain your urls and dimensions for the viewport. Example configuration:
{
"domain": "https://site.com",
"renderWaitTime": 2500,
"pages": [
{
"src": "/",
"target": "app/design/frontend/THEMEPATH/THEMEPATH/web/css/cms-critical.css"
},
{
"src": "/category/",
"target": "app/design/frontend/THEMEPATH/THEMEPATH/web/css/category-critical.css"
},
{
"src": "/PDP.html",
"target": "app/design/frontend/THEMEPATH/THEMEPATH/web/css/product-critical.css"
},
{
"src": "/checkout/#shipping",
"target": "app/design/frontend/THEMEPATH/THEMEPATH/web/css/checkout-critical.css"
}
],
"dimensions": [
{ "width": 320 }, // Height is optional
{ "width": 767, "height": 3000 },
{ "width": 992 },
{ "width": 1200 },
{ "width": 1424 }
]
}
In the pages array, src is the page you want critical css from and target is the place to drop the newly generated critical css bundle. Dimensions only require widths (this differs per project). The height will be chosen based on a set of most used resolutions:
const standardViewports = [
{ width: 1920, height: 1080 },
{ width: 414, height: 896 },
{ width: 1536, height: 864 },
{ width: 1366, height: 768 },
{ width: 375, height: 667 },
{ width: 360, height: 640 },
];
If you want to explicitly use a set height, you may add it to the dimensions array like this (it will overwrite the default):
"dimensions": [
...
{ "width": 767, "height": 3000 },
...
]
To use this package, you need to run: npx iodigital-criticalcss
in the command line.
There are some environment variables that can be used while generating the criticalcss.
export DOMAIN=https://www.google.com
npx iodigital-criticalcss
or
DOMAIN=https://www.google.com npx iodigital-criticalcss
FAQs
NPM package to generate critical css via a configuration file
The npm package iodigital-criticalcss receives a total of 12 weekly downloads. As such, iodigital-criticalcss popularity was classified as not popular.
We found that iodigital-criticalcss demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?
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.
Security News
PyPI now supports iOS and Android wheels, making it easier for Python developers to distribute mobile packages.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.