Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
extract-css-media-cli
Advanced tools
A cli wrapper around the extractCssMedia npm module, to extract media query selectors from a given css file and write them into separate files.
This helps to load different css files per media query. When a media query doesn't match on load, modern browsers don't load them in a render blocking way.
I recommend installing the module globally to easily access it everywhere in your console.
sudo npm i extract-css-media-cli -g
The exposed command is extractCssMedia which takes several options. The only required option is --inputFilename=[your-css-file].
The program reads the given css file, parses out the media queries which satisfy the minRules option (see below) and stores all found media query bundles into separate files. The rest of the css will be written to a file which is suffixed with _nomedia.
This option is passed to the extract-media-query module. It specifies a minimum number of rules for a media query to be required to split that media query definitions into an extra string.
The background for that is, that there are sometimes media queries which contain only a little amount of definitions. In that case it often makes sense to keep them in the overall css.
This option is passed to the extract-media-query module which passes it further to css.parse. When set to true, the output css gets minified.
The directory to write the separated files to.
If set to true (default), all characters in the filename which don't match /[0-9a-z._]/i get replaced by an underscore. If set to false, the output filenames will contain whitespaces and probably parenthesis. This happens because the media query will get used in the output filenames.
If set to true the program shows the link tags which you can use in your html. To ensure, that the paths are fitting, the program should be run in the right folder (depending on your web server configuration)
extractCssMedia --inputFilename=test.css --showLinkTags=true
The compress option doesn't produce a fully minimized css. Like you can already see in the example output, the splitting semicolon for css definitions is also added to the last statement of each definition. If you really want to have the smallest css, you should use a real minifier after the media query separation.
FAQs
command line tool to split a css file into it's media selectors
We found that extract-css-media-cli demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.