-
Notifications
You must be signed in to change notification settings - Fork 5.9k
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
Add srcset support for data-lazy #1661
base: master
Are you sure you want to change the base?
Add srcset support for data-lazy #1661
Conversation
+1, this would be a great addition for apps with responsive images. |
👍 |
2 similar comments
👍 |
+1 |
Yes, please. This feature would be most welcome. |
Duplicate of #916 ? |
+1 |
+1 - This would take it to the next level! p.s.sorry for missing this before posting Does lazy loading work with srcset? #2260 |
+1 |
@leggomuhgreggo what do you think? |
It's a great idea. I think Also anticipating requests for the full |
+1 |
1 similar comment
+1 |
can we get these conflicts resolved? |
I'm really looking forward to this update, is there any eta perhaps? |
+1 |
1 similar comment
+1 |
+1 |
any update on this on another branch or release? |
Used this and it doesn't seem to load srcset correctly, on desktop its loading the large image as it should but on mobile its loading both large first then small (at same time but in that order in the requests) EDIT: I see progressive should be used this brings another issue with this modification. When used on a page with say 20 images in a slider the entire page will freeze up and will also increase the memory / CPU usage of Chrome by a huge amount and then unfreeze once all images have been loaded. |
Similar problem with @GSC89 - two images are being loaded according to Chrome + Firefox Network tabs (although regardless of screen size), defeating the purpose of srcset. One is the correct image from the available images in the The generated markup for each slide seems correct, for example, if I was to copy the generated markup for a slide and use it directly in a template, the srcset aspects do work as intended (eg the following generated slide from this referenced demo correctly loads just the one relevant image, if pasted directly into php template - but it won't benefit from lazy-load obviously!)...
Is there any definitive demo of lazy-load + srcset (+ ideally 'anticipated')? Some demos out there use sligltly different syntax (eg data-lazy, data-lazy-srcset etc). |
Looks like the reason two images are loaded is because I've looked at a way of setting the src, srcset, sizes attributes all at the same time with the aim of just downloading the one relevant image. Replacing
The imageToLoad.onload and imageToLoad.onerror functions updating accordingly and I'm having issues with some later slides not loading the image, so still needs work, but thought I'd mention this idea. |
Any Idea when this change might come to a release? |
I'm also voting for this issue. It's a must to avoid downloading x2 or x5 images at the same time if you have different image size for responsive. |
+1 |
Hi, it’s not about a new feature!
It’s about having a working example of slick under Jquery 3. ..
What I have done - as a rescue - is to throw out the ready trigger part and call the whole routine at the end of of the HTML file. It seems to works, but …
I have found that gitlab is using your component Slick quite nicely, and I want to in a very different context something similar
And using bootstrap 4, I need jquery 3.x
It’s just for newcomers
Best regards, and thanks for this very nice tool
Mathias
On 22 December 2017 at 15:42:29, Tom Bestebreurtje (notifications@github.com) wrote:
It seems that this feature was already released in 1.7.1. Close?
#2681 #2456 #2981 #2942 #2843
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or mute the thread.
|
Needs bugs addressing before closing issue. Multiple images are loaded by the browser as mentioned above, defeating the purpose of using srcset. |
I noticed a site the other day using slick with srcset for their hero slider and it seems to be working good on all browsers www.insomniac.com |
Is it possible to combine slick carousel built with picture tag items that also uses lazyLoad option? I only found srcset example https://github.com/kenwheeler/slick/pull/2681/files but it won't do in my case. |
If you are using source elements, you can do it like this:
Works for me. Doesn't work if you have srcset on the img element, but can be adapted. But could be awesome avoiding this :) |
@projer While your solution seems to work I found it to have a serious drawback: It always first loads the normal version and then afterwards loads the alternative version from the Any other idea how to fix this? |
Here is my solution based on @projer's solution:
|
@rahulbpatel's solution is perfect if you don't want to load two srcs. I'm using it for a slightly different case as I'm loading webp or jpg files depending on browser support. This is an example markup (javascript code would be the same as in @rahulbpatel's solution).
|
Unfortunately, PageSpeed Insights doesn't support @projer solution. I opened issue in Lighthouse repository. Write if any ideas. Thanks. |
@rahulbpatel Thank you for the suggestions, very interesting. Do you have any idea how to get around this? I'm using the latest Slick release. |
Do you have an example online to check out? I can't tell from your description why content is not showing up |
Sorry I missed your reply @rahulbpatel, been away for a while. I'd love to produce a reduced test case, but sadly crushed under a pile of other people's bugs being thrown at me. We've de-prioritised the issue for now, frustratingly, but I hope to come back to it later. |
Here is my workaround, in case someone faces the same issue while picture elements are not supported and still wants the img tag inside the picture to hold an actual image.
Custom Lazyload:
|
Any idea when this will be ready? @kenwheeler |
I'm locking for this feature too. I wold like to implement webp images and it wold need the picture tag to work correctly as fallback |
You can solve this issue using
code example by me:
|
+1 |
Any Update when this will be ready? |
This input can be added as a separate proposal. I'm only posting it here as a reference. Initial thought being this: What if my slide's mobile image is different than the desktop image? According to srcset, if the larger resolution image is already in browser's cache the browser will choose to show the larger resolution image instead of the smaller resolution on mobile. There is a small possibility this happens when switching between landscape and portrait modes on a mobile/tablet. |
Any update on this? |
I just use a lazy load library like lazysizes |
This solution is still an expiremental one and is not supported by all the browsers ... |
Hello,
During working with my project, I need to use slick with the picturefill and lazyload the image. I found that slick has
data-lazy
for that, but it links withsrc
, so I made some minor modifications to the source code to add support fordata-lazy-srcset
->srcset
.Here is a very simple demo to prove my
data-lazy-srcset
works: https://jsfiddle.net/pwq4g54b/embedded/result/Thank you.