svelte-image icon indicating copy to clipboard operation
svelte-image copied to clipboard

Option to disabling lazy loading globally

Open d4h0 opened this issue 4 years ago • 1 comments

Thanks for adding the 'lazy' prop to the Image component.

It would be great if there was a global option to disable lazy loading completely.

Or – probably even better – an option to disable lazy loading by default (so it's still possible to activate lazy loading with the 'lazy' prop for individual images).

Rich Harris (creator of Svelte) posted a very relevant tweet about this a few days ago:

https://twitter.com/Rich_Harris/status/1208040145385086982

:)

Btw., I think the 'lazy' props description would be clearer, if it was something like:

"lazy default: true - false disables lazy loading of images."

(instead of "lazy default: true Disables Waypoint.")

Maybe not everyone knows what Waypoint is.

d4h0 avatar Dec 28 '19 16:12 d4h0

@matyunya It's quite simple to achieve this via svelte <script context=module>:

<script context="module">
  let defaults = {
    lazy: true,
  };

  export function setDefaults(v) {
    defaults = v;
  }
</script>

<script>
  import Waypoint from "svelte-waypoint";

  // ...
  export let lazy = defaults.lazy;
  // ..
</script>

artemjackson avatar Mar 16 '20 23:03 artemjackson