
Security News
vlt Launches "reproduce": A New Tool Challenging the Limits of Package Provenance
vlt's new "reproduce" tool verifies npm packages against their source code, outperforming traditional provenance adoption in the JavaScript ecosystem.
novicell-lazyload
Advanced tools
Image lazyloading script in vanilla javascript
Written in pure Vanilla JS, depends on lazysizes and some kind of serverside image processor as the imageprocessor.net. It ships with examples for easy implementation with the novicell-frontend setup.
npm install novicell-lazyload@next --save
Or simply:
npm i novicell-lazyload@next
Import novicell-lazyload as a module in your javascript file that observes the images:
import 'novicell-lazyload';
This script lazyloads by swapping the data-src
or data-srcset
to an actual src
or srcset
.
For all implementations you should have a lazyload
-class and data-query-obj
on the image. Everything inside the data-query-obj is general settings that is applied on every src in the srcset as a querystring".
For extra plugins and complete feature list, please reference the lazysizes documentation.
For images with fixed sizes we recommend using a specific srcset, as this is the fastest.
<img class="lazyload" data-src="/dist/images/test.jpg" alt="Cool image" data-query-obj='{"mode":"crop", "quality":"70", "center": "0.8,0.3"}'
data-srcset="/dist/images/test.jpg?width=1500&heightratio=0.6 1000w,
/dist/images/test.jpg?width=900&heightratio=0.6 800w,
/dist/images/test.jpg?width=400&heightratio=1 500w"/>
For images with variable sizes, eg. a full width banner with a fixed height, or just an image added in the CMS inside a random grid column, we recommend the "measure"-feature.
This feature will get the size of the parent element, and add it as query strings for this image.
<img class="lazyload lazyload-measure" data-src="/dist/images/test.jpg" alt="Cool image" data-query-obj='{"mode":"crop", "quality":"70", "center": "0.8,0.3"}'/>
If you just want auto height you can add the attribute ´data-height-ratio="0"´ You can also pass a height-ratio, this will set the size accordingly.
Useful height ratios:
0
: Auto height
0.5
: Half height as width
0.5625
: 16:9 format
0.625
: 16:10 format
1
: Square image
2
: Twice height as width
<img class="lazyload lazyload-measure" data-src="/dist/images/test.jpg" alt="Cool image" data-height-ratio="0" data-query-obj='{"mode":"crop", "quality":"70", "center": "0.8,0.3"}' />
This uses the "measure"-feature only adding the image as a background image on the parent element, instead of an actual <img>
-tag.
<img class="lazyload lazyload-measure lazyload-bg" data-src="/dist/images/test.jpg" alt="Cool image" data-query-obj='{"mode":"crop", "quality":"70", "center": "0.8,0.3"}'/>
For extending the component please reference the Novicell wiki page 🕮.
FAQs
Novicell script for lazyloading images.
The npm package novicell-lazyload receives a total of 34 weekly downloads. As such, novicell-lazyload popularity was classified as not popular.
We found that novicell-lazyload demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 9 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
vlt's new "reproduce" tool verifies npm packages against their source code, outperforming traditional provenance adoption in the JavaScript ecosystem.
Research
Security News
Socket researchers uncovered a malicious PyPI package exploiting Deezer’s API to enable coordinated music piracy through API abuse and C2 server control.
Research
The Socket Research Team discovered a malicious npm package, '@ton-wallet/create', stealing cryptocurrency wallet keys from developers and users in the TON ecosystem.