You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

svelte-disable-preload

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

svelte-disable-preload

![minified](https://img.shields.io/bundlephobia/min/svelte-disable-preload/0.0.2?style=for-the-badge) ![minified + zipped](https://img.shields.io/bundlephobia/minzip/svelte-disable-preload/0.0.2?style=for-the-badge)

0.0.3
latest
Source
npmnpm
Version published
Weekly downloads
149
-46.21%
Maintainers
1
Weekly downloads
 
Created
Source

svelte-disable-preload

minified minified + zipped

SveltKit provides a client-side router that handles navigation when anchor elements are clicked. It can also be configured to preload data to make your app seem "snappier". It does this by listening for various click, mousedown, mousemove, and touchstart events on the document which will bubble from elements.

For typical "web-app" use, this is no problem. But if you're working with HTML canvas elements and requestAnimationFrame animations, you may not want these extra event handlers being invoked - it can introduce a slight 'juddering' effect and spoil an otherwise smooth animation.

There is an option to disable it but this only disables the behavior from being invoked, i.e. the preloading itself - the event listeners are still there.

This package provides a simple action to apply noop event listeners to an element that prevent the document-level SvelteKit event handlers being invoked.

Usage

Install using your package manager of choice, e.g.

pnpm i svelte-no-preload

Import it into your component and use: it on an element:

<script lang="ts">
  import { disablePreload } from 'svelte-disable-preload'
</script>

<canvas use:disablePreload />

Your canvas interactions should now be slightly smoother.

Keywords

svelte

FAQs

Package last updated on 29 Apr 2024

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