$(myImageEl).waitForImages() doesn't work
See original GitHub issueIt 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:
- Created 7 years ago
- Comments:5 (3 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I will close as outside the functionality of this plugin.
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:
https://github.com/alexanderdickson/waitForImages/blob/master/src/jquery.waitforimages.js#L155