-
Notifications
You must be signed in to change notification settings - Fork 5
Feature/lazyloading #119
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
Feature/lazyloading #119
Conversation
…nt in the network tab (for testing pages with lots of images)
Convert directory to be lazy loaded
…it never is on a real site.
…e it messes with slicks height
let lazyImage = entry.target; | ||
|
||
if(lazyImage.tagName != 'IMG') { | ||
lazyImage.style = "background-image: url('"+lazyImage.dataset.src+"')"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would this overwrite any other inline styles on the image?
Feel like this may be a better approach to swap out the background-image:
lazyImage.style.backgroundImage = "url('"+lazyImage.dataset.src+"')";
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yea i'm good with doing that! I'll make the change.
… directly in other templates
…eas that can use it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added a custom blade directive for an image @image('path-to-image', 'alt text', 'optional-class-name')
Its wonky how you pass in multiple optional parameters, but I got the idea from this to split the string: https://zaengle.com/blog/exploring-laravels-custom-blade-directives . I'm looping through to check how many params were passed in and then I set them as blank strings (so they are optional) if not passed in.
let lazyImage = entry.target; | ||
|
||
if(lazyImage.tagName != 'IMG') { | ||
lazyImage.style = "background-image: url('"+lazyImage.dataset.src+"')"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yea i'm good with doing that! I'll make the change.
Leaving this open for a bit as I want to discuss it with the team.
IntersectionObserver
which figures out what images are in bound in the users viewport and lazy loads them to save bandwidth.b-lazy
so everything usesIntersectionObserver
partials.image-fake
so its easier to useImage List Rotate
andImage Button List
@image('path-to-image', 'alt text', 'optional-class-name')