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.

$(myImageEl).waitForImages() doesn't work

See original GitHub issue

It looks like the library works only elements that are children of the selector. Any particular reason? In my case, I prefer waiting only on specific images, so rather than specifying a container, the selector points directly to the image. Unfortunately, waitForImages doesn’t find the src in that case…

// doesn't work
$('<img src="..." />')
    .appendTo('body')
    .waitForImages()
    .then(function() {
        console.log('executed immediately, because image not detected');
    });

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
alexanderdicksoncommented, Feb 18, 2017

I will close as outside the functionality of this plugin.

0reactions
andrejpavloviccommented, Jun 8, 2016

waitForAll would work, but it’s more of a workaround I guess. Ideally an edge case like this would be handled just like other cases. Adding something like this would do the trick I think:

obj.find('img:has-src').addBack('img:has-src')

https://github.com/alexanderdickson/waitForImages/blob/master/src/jquery.waitforimages.js#L155

Read more comments on GitHub >

github_iconTop Results From Across the Web

Official way to ask jQuery wait for all images to load before ...
With jQuery, you use $(document).ready() to execute something when the DOM is loaded and $(window).on("load", handler) to execute something when all other ...
Read more >
Wait for images to load and then execute all other code
Wait for images to load and then execute all other code ... That doesn't fire until all images have been loaded. ... waitForImages(function(){...
Read more >
Resource loading • Chromatic docs
Chromatic waits for resources like images and fonts to load before capturing a snapshot. When resources fail to load it leads to unintended...
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