Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@svelte-bin/image

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@svelte-bin/image

action for image

  • 0.0.1
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

@svelte-bin/image

action for image

Svelte Lazy Image

Lazy Image with IntersectionObserver and cache action for Svelte/SvelteKit.

Installation

// Using Yarn to install
yarn add --dev @svelte-bin/image

// or if you prefer NPM
npm install --save-dev @svelte-bin/image

Usage Sample

<script>
	// 	for first time you will get all image from this load from internet
	// 	its normal because no image cached before
	// 	so if you wanna see its working, try it will with change looping or something reactivity will work
	import { lazyimage } from '@svelte-bin/image';
	const placeholder = 'https://media3.giphy.com/media/3oEjI6SIIHBdRxXI40/200.gif';
	// 	try change size and see image load from internet or cache
	const src = 'https://random.imagecdn.app/200/250';
	const alt = 'Random Image';

	let onlyForLooping = [];
	for (let i = 0; i < 100; i++) {
		onlyForLooping[onlyForLooping.length] = '';
	}
</script>

<!-- No Cache -->
<img
	use:lazyimage={{ cache: false }}
	src={placeholder}
	data-src={src}
	{alt}
	on:cacheload={() => console.log('load from cache')}
	on:imgload={() => console.log('Load from internet')}
/>

<!--
Check console when scrolling. if your brwoser support intersection observer
and you enable cache,another image with same url (cached) will use instead of load from internet
-->
{#each onlyForLooping as _}
	<!-- With Cache  -->
	<img
		use:lazyimage
		src={placeholder}
		data-src={src}
		{alt}
		on:cacheload={() => console.log('load from cache')}
		on:imgload={() => console.log('Load from internet')}
	/>
{/each}

FAQs

Package last updated on 23 Nov 2023

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