Security News
The Risks of Misguided Research in Supply Chain Security
Snyk's use of malicious npm packages for research raises ethical concerns, highlighting risks in public deployment, data exfiltration, and unauthorized testing.
responsive-loader
Advanced tools
A webpack loader for responsive images. Creates multiple images from one source image, and returns a srcset
. For more information on how to use srcset
, read Responsive Images: If you’re just changing resolutions, use srcset.. Browser support is pretty good.
npm install responsive-loader jimp --save-dev
responsive-loader uses jimp, a pure JS image manipulation library (so no other dependencies, yay :v:), to transform images which needs to be installed alongside responsive-loader.
// Outputs three images with 100, 200, and 300px widths
const responsiveImage = require('responsive?sizes[]=100,sizes[]=200,sizes[]=300!myImage.jpg');
// responsiveImage.srcSet => '2fefae46cb857bc750fa5e5eed4a0cde-100.jpg 100w,2fefae46cb857bc750fa5e5eed4a0cde-200.jpg 200w,2fefae46cb857bc750fa5e5eed4a0cde-300.jpg 300w'
// responsiveImage.images => [{path: '2fefae46cb857bc750fa5e5eed4a0cde-100.jpg', width: 100}, {path: '2fefae46cb857bc750fa5e5eed4a0cde-200.jpg', width: 200}, {path: '2fefae46cb857bc750fa5e5eed4a0cde-300.jpg', width: 300}]
React.render(<img srcSet={responsiveImage.srcSet} src=[responsiveImage.images[0].path] />, el);
sizes: array
: specify all widths you want to use; if a specified size exceeds the original image's width, the latter will be used (i.e. images won't be scaled up)quality: integer
: JPEG compression quality; defaults to 95
ext: string
: either png
, jpg
, or gif
; use to convert to another format; defaults to original file's extensionbackground: hex
: Background fill when converting transparent to opaque images; defaults to 0xFFFFFFFF
(note: make sure this is a valid hex number)1x
, 2x
sizes.2fefae46cb857bc750fa5e5eed4a0cde-100.jpg
, 2fefae46cb857bc750fa5e5eed4a0cde-200.jpg
, etc.FAQs
A webpack loader for responsive images
The npm package responsive-loader receives a total of 12,058 weekly downloads. As such, responsive-loader popularity was classified as popular.
We found that responsive-loader demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 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
Snyk's use of malicious npm packages for research raises ethical concerns, highlighting risks in public deployment, data exfiltration, and unauthorized testing.
Research
Security News
Socket researchers found several malicious npm packages typosquatting Chalk and Chokidar, targeting Node.js developers with kill switches and data theft.
Security News
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.