Improvement of b-img-lazy component
See original GitHub issue@victorhramos, @KonradDeskiewicz Let’s continue the conversation here. Initial issue #1619
There is an initial check which is executed when <b-img-lazy>
is mounted
and activated
but due to the missing getBoundingClientRect
of the html element nothing happens.
I would like to improve this component because it is very useful. Currently lazy loading does only work when the page scrolls. Not optimal when you have dynamic content and want to lazy load, but there is not enough content for the page to scroll. See my codesandbox below. https://codesandbox.io/s/z5pkrx89m
In addition it would be nice to have state classes like <router-link>
has, e.g.
img-lazy-blank
whenblank
image is shown. Could be used to apply opacity or other css filtersimg-lazy-src
whensrc
image is shown.
And a last improvement that comes to my mind is async loading of src
images e.g.
const prefetchImage = src => new Promise((resolve, reject) => {
const img = new Image();
eventOn(img, 'load', () => {
resolve();
});
eventOn(img, 'error', () => {
reject();
});
img.src = src;
});
Issue Analytics
- State:
- Created 5 years ago
- Reactions:5
- Comments:14 (5 by maintainers)
Top Results From Across the Web
<Lazy> rendering in Vue to improve performance - Medium
In this article, I'll focus on the 3rd category and I'll try to do it via introducing a universal <Lazy> component.
Read more >bootstrap-vue - UNPKG
src/components/button-toolbar/button-toolbar.js",". ... default: THROTTLE\n }\n}\n\n// @vue/component\nexport const BImgLazy = /*#__PURE__*/ Vue.extend({\n ...
Read more >Image | Components - BootstrapVue
Create responsive images, optionally adding lightweight styles to them — all via props. Support for rounded images, thumbnail styling, alignment, ...
Read more >Improving performance in your Vue 3 application by Lazy ...
Vue 3 has introduced several new features to help you achieve this easily through the improvements to the async component API Fast loading ......
Read more >Building an effective Image Component - Chrome Developers
Lighthouse lists multiple opportunities to optimize images and improve web vitals as part of its best practices audit. Some of the common ...
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
PR #2382 should fix this issue, as well as adds in a new
show
prop to force show the image.Also, bubbled
transitonend
events are now monitored, sob-img-lazy
should work inside elements with transitions that show/slide/scroll the content (on browsers that support thetransitionend
event).Yeah, let me check the code and see if we can make an adjustment to the mounted() hook.