g-image loads twice
See original GitHub issueDescription
All g-image load twice, max size and correct viewport size
Steps to reproduce
Thoroughly tested, should be easy to reproduce, or some platform/node version issue
gridsome create gridsome-test
Index.vue
<g-image alt="Example image" src="~/assets/pexels-photo-289586.jpeg" width="1920"/>
img {max-width: 100%;}
develop and build versions same result
Expected result
Only load correct size
Actual result
Loads twice
Environment
Libs:
- gridsome version: 0.5.0, 0.6.0, 0.6.1
- @gridsome/cli version: 0.1.0
Browser:
- [ x ] Chrome (desktop) version 74
- [ x ] Firefox version 68
For Tooling issues:
- Node version: 11.8
- Platform: Windows
Others:
Windows 8.1, npm
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (4 by maintainers)
Top Results From Across the Web
Image somehow loads twice - jquery - Stack Overflow
Is it just me or are there two image tags in this line? $("#content").css({width:newWidth+'px',height:newHeight+'px',margin:'0'}) ...
Read more >Class GTile — Froggit 2.0a documentation - Cornell CS
This class is a variation on GImage for drawing an image file. ... it will repeat the image twice horizontally and four times...
Read more >If I use an image twice on the same page, will it increase the ...
Yes but by a very minute difference. The browser will cache the image the first time it loads, so any subsequent display of...
Read more >Improving a Gridsome website performance - Codegram
Gridsome offers a g-image component that outputs an optimized progressive image. This component loads a very light base64 blurred image by ...
Read more >1996 Fiddler on the Roof VHS VCR Double Tape Movie Rated G
1996 Fiddler on the Roof VHS VCR Double Tape Movie Rated G image 1. zoom image 2 of 10 ... Loading. Rare find...
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 Free
Top 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
@robaxelsen Done.
I had a similar issue with an own implementation of lazy-loaded responsive images about half a year ago. But in my case the image was loaded twice only in Safari for some reason. I still hope that the description of my problem and solution can help here.
In my case I left the
src
andsrcset
attributes empty at first. When intersecting the image, the state in my Vue image component changed so that bothsrc
andsrcset
were filled with the correct strings. The browser then started downloading the image specified in thesrc
attribute, closely followed by downloading the correct image from thesrcset
attribute.I found out that changing the order of the
src
andsrcset
attributes in my Vue single file component solved the problem:The problem was caused by the browser immediately (literally immediately) firing a request if an
<img>
source changes while Vue is setting and updating the attributes imperatively under the hood (it can’t set both attributes at once, it has to do it in sequence).The
src
attribute was set first, so the browser fired a request to the path specified in there. Afterwards thesrcset
attribute was set and because thesrcset
attribute has precedence oversrc
, the image source changed again and the browser fired another request.So my proposal to the Gridsome team is: Try to make sure that
srcset
is always set and updated beforesrc
in<g-image>
. Hopefully that should resolve the issue.