-
Notifications
You must be signed in to change notification settings - Fork 169
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Galleria: Load first image earlier #307
Galleria: Load first image earlier #307
Conversation
Codecov Report
@@ Coverage Diff @@
## master #307 +/- ##
======================================
Coverage 87.9% 87.9%
======================================
Files 20 20
Lines 1463 1463
======================================
Hits 1286 1286
Misses 177 177 Continue to review full report at Codecov.
|
Galleria triggers loading of the main gallery iamge via javascript which has two problems. It only triggers the load when javascript has been processed and loads it at the same time as the second and third image which means it's competing with background images for bandwidth. We know that the first image will always be seen, so trigger a load in the document rather than waiting for js to do it.
52163ce
to
d81476f
Compare
I agree it would be useful to optimize the page loading for albums with many images, but your solution sounds too hacky and I think we could get better results with galleria loading JSON data: |
Loading an asset in a hidden div, or a suppressed element is an established method for prioritised loading without javascript. It’s inelegant, to be sure, but until preload gets wider support, I don’t think there’s a nicer way. I’ve done a quick prototype of json loading with lazy loading of thumbnails: edwinsteele@552db1e From that I can see that json+lazyload does delay the thumbnail loading, so does reduce contention however the image loading only begins after js has been loaded and even then it triggers a download of the first 3 images in parallel. I think the json work will give a win, and I think this will give us an improvement too. Is it possible to get this in? I’ll followup with the json work. |
Yes, the json approach seems actually much cleaner, it would be great to get this if you are ready to finalize your patch (which seems already quite good). |
I’ve opened #312 for the switch to json. Are you happy to merge this too? I would prefer to use this solution for loading the first image earlier, but I can rebase with the more elegant but less supported preload tag if you feel strongly about the “hackiness" |
|
Yes, it still makes quite a difference. On my test I saw the json branch have the first image loaded after 1.3s compared to 0.7s with json + this patch. I would also like to move to preload once there’s more support. I’ll make a note to look at preload support in 6 months for review. |
Ok, let's go with this for now, thanks. |
…age-load Galleria: Load first image earlier
Galleria triggers loading of the main gallery iamge via javascript
which has two problems. It only triggers the load when javascript
has been processed and loads it at the same time as the second and
third image which means it's competing with background images for
bandwidth. We know that the first image will always be seen, so
trigger a load in the document rather than waiting for js to do it.
Comparison (this patch is the only difference between the two runs): https://webpagetest.org/video/compare.php?tests=180303_KS_87bf0854a5a346d90d71fad871ae423c,180302_9A_ff950fed21454ed20fd5e9750d3157ca