Socket
Socket
Sign inDemoInstall

parse-srcset

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

parse-srcset

A spec-conformant JavaScript parser for the HTML5 srcset attribute


Version published
Weekly downloads
2.7M
increased by19.47%
Maintainers
1
Weekly downloads
 
Created

What is parse-srcset?

The parse-srcset npm package is a utility for parsing the 'srcset' attribute of HTML <img> elements. It helps in breaking down the 'srcset' attribute into its individual components, making it easier to work with responsive images in web development.

What are parse-srcset's main functionalities?

Parsing srcset attribute

This feature allows you to parse a 'srcset' attribute string into an array of objects, each representing an image candidate with its URL and descriptor.

const parseSrcset = require('parse-srcset');
const srcset = 'image1.jpg 1x, image2.jpg 2x';
const parsed = parseSrcset(srcset);
console.log(parsed);

Handling different descriptors

This feature supports parsing different types of descriptors such as width descriptors (e.g., '100w') and pixel density descriptors (e.g., '2x').

const parseSrcset = require('parse-srcset');
const srcset = 'image1.jpg 1x, image2.jpg 2x, image3.jpg 100w';
const parsed = parseSrcset(srcset);
console.log(parsed);

Other packages similar to parse-srcset

FAQs

Package last updated on 10 Dec 2016

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc