- "Modern Browser" compliant (no IE)
- A11y
- Lazy-loading
lazyloadattribute (https://caniuse.com/#feat=lazyload)IntersectionObserverpolyfill forlazyload- Manual trigger
- Placeholder
- LQIP (
- SQIP
- Responsive
- srcset (https://caniuse.com/#feat=srcset)
- picture (https://caniuse.com/#feat=picture)
- "Adaptive"
- Use progressive image formats (ie. WebP) if available
- Handle "slow networks"
- Ability to "cancel" a download
- Use async decoding (
decodingattribute??)
- SSR/pre-rendering
- Handle users without javascript
- Customization
- Icons
- Text/i18n/i10n
- Theme/Styling
- Additional UX, nice-to-haves
- Network error
- 404 error
- Offline
- Hooks
Requires X feature-set and Y Browser are compliant
How to keep the component small and progressive
- https://github.com/stereobooster/react-ideal-image/blob/master/introduction.md
- https://medium.com/@marcelvbeek1996/our-implementation-of-lazy-loading-responsive-images-with-the-image-observer-and-picture-element-6634138ef5d
- https://afarkas.github.io/lazysizes/index.html
- https://developer.mozilla.org/en-US/docs/Learn/HTML/Multimedia_and_embedding/Responsive_images
- https://www.html5rocks.com/en/tutorials/responsive/picture-element/
- https://developers.google.com/web/fundamentals/performance/lazy-loading-guidance/images-and-video/
- https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/Image
- https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/decode
- https://github.com/notwaldorf/lazy-image/
Features
Minimal
Based on latest ES2018 standards, Webcomponents (extends HTMLElement), extensible using mixins
Lazy-Loading
This comes built into Modern Browsers and shipping a separate polyfill will allow us to reduce bloat.
NOTE: Detect if
lazyloadis supported with'lazyload' in new Image()NOTE: If
lazyloadattribute is not supported, ability to pull in polyfill for it to support it. Extract into a separate file usingIntersectionObserver.NOTE: Requires
IntersectionObserversupport as well, possibly need to polyfill that prior to thelazyloadattribute support polyfillQUESTION: How can a user manually trigger lazy-loading
QUESTION: Should we create a declarative
IntersectionObserverthat we can wrap the image in?Placeholder
Removes dead space of loading image. LQIP/SQIP are techniques that work. Any string should be allowed in this field
NOTE: Using
lqip,sqip,lqip.macro, orsqip.macrowould be able to be passed through the placeholder.QUESTION: Do I need to pass it through as an object or can I just pass it directly? (Double-check API)
QUESTION: Should we show some kind of loader if no
placeholderis passed?Responsive
Allows for
sourcetags to be slotted for responsive support.NOTE: All qwirks that would apply to the
pictureandsourcetags would apply here.QUESTION: Should we offer a component without this option that is just a basic
imgtag, instead of thepicturetag?QUESTION: How should we handle the default
imgtag if nosrcis supplied?Adaptive
Progressive Image Format support
Using the native
typeattribute onsourceshould allow for experimental image types to be used if the UA supports it.Slow Networks
or
Read the
navigator.connection.dataSaver,navigator.connection.effectiveType. Default to!== '4g'fallback. Allow manual threshold of a number (ms) or string (effectiveType).If "slow-network" is detected,
Allow a slotted "click to load" icon for configurability.
NOTE: Cancelling of the iamge will be handled via the
Imagevariable. SettingImage.srcto something different or''will cancel the previous request.Offline Network
Should be similar to slow networks and check
navigator.onLine.SSR
QUESTION: How do we handle this? / Should we handle this?
QUESTION: Would it make sense to make this more of a decorator for the
picture/imgtags to allow better SSR handling?Configurability
Icons
Expose configurability of the icons through named slots. "network error", "404", "offline", "click to load" all will have named slots.
i18n
/shrug
QUESTION: Should we expose a
getMessagesfunction that gets the state and does something with it?Themeing
Make use of the
::part/::themeAPIQUESTION: Will this cover everything?