
Security News
Node.js Homepage Adds Paid Support Link, Prompting Contributor Pushback
A new Node.js homepage button linking to paid support for EOL versions has sparked a heated discussion among contributors and the wider community.
@s-ui/critical-css
Advanced tools
Extract Critical CSS from a set of URLs for an app
critical-css
folder.critical.json
file that could be read for every path to extract the critical-css.@s-ui/critical-css-middleware
to extract to use in your Express app the CSS.Install package to your project:
npm install @s-ui/critical-css -D
In order to extract critical css and match extracted files with your page or route you can use two approaches:
You can combine both of them.
Additionally there are two optional config parameters:
requiredClassNames
: A list of required css class names. If they aren't present in the generated Critical CSS, it would be discarded. By default there would be 2 retries to try to get the correct Critical CSSretries
: Number of retries if the requiredClassNames aren't present in the Critical CSS. By default it's 2.path-to-regex
:You can use Express Route Tester to create and validate that your Path-to-Regexp works as expected.
Example:
// scripts/get-critical-css-for-routes.js
import {extractCSSFromApp} from '@s-ui/critical-css'
const config = {
hostname: 'http://localhost'
}
const routes = {
'/:lang': {
url: '/es'
},
'/:lang/catalogo-productos': {
url: ['/es/catalogo-productos', '/en/catalogo-productos']
}
}
extractCSSFromApp({config, routes})
displayName
Example:
// scripts/get-critical-css-for-routes.js
import {extractCSSFromApp} from '@s-ui/critical-css'
// Page display names
const displayNames = {
home: 'Home',
list: 'List'
}
const config = {
hostname: 'http://localhost'
}
const routes = {
[displayNames.home]: {
url: '/es'
},
[displayNames.list]: {
url: '/es/catalogo-productos',
requiredClassNames: ['.ma-AdCardV2'],
retries: 3
}
}
extractCSSFromApp({config, routes})
FAQs
> Extract Critical CSS from a set of URLs for an app
The npm package @s-ui/critical-css receives a total of 3,687 weekly downloads. As such, @s-ui/critical-css popularity was classified as popular.
We found that @s-ui/critical-css demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 88 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
A new Node.js homepage button linking to paid support for EOL versions has sparked a heated discussion among contributors and the wider community.
Research
North Korean threat actors linked to the Contagious Interview campaign return with 35 new malicious npm packages using a stealthy multi-stage malware loader.
Research
Security News
The Socket Research Team investigates a malicious Python typosquat of a popular password library that forces Windows shutdowns when input is incorrect.