question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Expose a function to load specific images before they appear

See original GitHub issue

It would be useful to be able to preload certain images in advance when certain events are triggered (say, a menu is opened). Currently, though, the load function is not exported from the module. It would be useful to reuse it instead of having to write it by yourself.

The only issue I see is that the load function is configurable. Although I suppose, we could assign it to the lozad object.

Example:

import lozad from 'lozad'

const observer = lozad()
observer.observe()
document.addEventListener('menu:open', () => {
  observer.load('img.language-icon')
})

Though observer.load doesn’t sound right.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:2
  • Comments:6 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
ApoorvSaxenacommented, Oct 12, 2017

thanks for getting this done all the way @thiamsantos

0reactions
thiamsantoscommented, Sep 27, 2017

I just opened a pull request adding this feature

Read more comments on GitHub >

github_iconTop Results From Across the Web

Javascript - execute after all images have loaded
Once all the images are loaded, your console will show "All images ... this is safe to expose to the caller. return when.all(deferreds); ......
Read more >
Five Ways to Lazy Load Images for Better Website ...
Lazy loading images means loading images on websites asynchronously — that is, after the above-the-fold content is fully loaded, or even ...
Read more >
So, You Want To Pre-Load, Huh?
The primary reason that you would want to pre-load images would be to increase responsiveness, as in, decrease noticeable time lags.
Read more >
JavaScript Tutorial | Detect when images or the page has loaded
By using the " load " event within JavaScript, you are able to detect when the web page or images, scripts etc. have...
Read more >
Lazy Loading Images – The Complete Guide
Lazy Loading Techniques for images. Images on a webpage can be loaded in two ways - using the <img> tag, or using the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found