Skip to main content
Create new
Introduction
Reactivity
Props
Logic
Events
Bindings
Lifecycle
Stores
Motion
Transitions
Animations
Easing
SVG
Actions
Classes
Component composition
Context API
Special elements
Module context
Debugging
7GUIs
Miscellaneous
App.svelte
utils.js
<script>
import { lazy, lazyAll } from './utils.js'
let src = 'https://images.pexels.com/photos/164446/pexels-photo-164446.jpeg?auto=compress&cs=tinysrgb&h=750&w=1260';
</script>

<h1>
Lazy Load Images
</h1>
<p style="margin-bottom: 100vh;">
Feel free to scroll
</p>

<h2>
lazy
</h2>
<p>
Individual images
</p>
<img use:lazy={{rootMargin: '-100px'}} alt="" data-src="{src}" width="1260" height="750" />

<hr />

<h2>
lazyAll
</h2>

<p>
All the images in a <code>div</code> container.
</p>
<div use:lazyAll>
{#each Array(5) as _}
<article>
<h3>
Here's a cute dog
</h3>
loading Svelte compiler...
/* Select a component to see its compiled code */
result = svelte.compile(source, {
generate: ,
});
/* Select a component to see its compiled code */