
Security News
NIST Officially Stops Enriching Most CVEs as Vulnerability Volume Skyrockets
NIST will stop enriching most CVEs under a new risk-based model, narrowing the NVD's scope as vulnerability submissions continue to surge.
source-media-query-loader
Advanced tools
Load image according to media queries and source nodes
npm i source-media-query-loader
Create instance with the callback
The callback receive an object with 8 properties
| Argument | Value |
|---|---|
| src | the image source |
| width | the image naturalWidth |
| height | the image naturalHeight |
| media | the media query |
| img | the image node |
| x | the x focus point ratio, default to .5 |
| y | the y focus point ratio, default to .5 |
| attributes | an object with the original attributes values |
var ql = QueryLoader(function(data) {
// {src:"image.jpg", width:320, height:240, media:"(max-width: 700px)", img:img, x:.5, y:.5, attributes:object}
console.log(data)
})
ql.start()
Add a source to the QueryLoader
Argument data can be a dom node or a javascript object
| Format | Value |
|---|---|
| node | <source src="image.jpg" media="(width <= 700px)"/> |
| object | {src:"image.jpg", media:"(width <= 700px)"} |
The properties src and media are required
Add all <source> child of node
<div id="ref">
<source src="small.jpg" x="0.663774403" y="0.375375375" hd="small-hd.jpg" media="(width <= 700px)"/>
<source src="medium.jpg" x=".363" y=".484257871" media="(900px >= width > 700px)" />
<source src="large.jpg" media="(width > 900px)" />
</div>
ql.find(document.querySelector('#ref'))
Start the instance
If node is defined, starts the lazy loading mode. The image will be loaded if node will enter the viewport
The argument offset is only used in lazy mode. The argument is optional, default to 200
Stop the instance. The callback will no more be invoked
Kill the instance. Listeners and memory are cleared
MIT
FAQs
Load image according to media queries and source nodes
We found that source-media-query-loader 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.

Security News
NIST will stop enriching most CVEs under a new risk-based model, narrowing the NVD's scope as vulnerability submissions continue to surge.

Company News
/Security News
Socket is an initial recipient of OpenAI's Cybersecurity Grant Program, which commits $10M in API credits to defenders securing open source software.

Security News
Socket CEO Feross Aboukhadijeh joins 10 Minutes or Less, a podcast by Ali Rohde, to discuss the recent surge in open source supply chain attacks.