All Projects → andreruffert → Progressive Image Element

andreruffert / Progressive Image Element

Licence: mit
⚡️ <progressive-image> custom element

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Progressive Image Element

Elements
Lazy load Angular Elements (or any other web components / custom elements ) with ease!
Stars: ✭ 223 (-3.46%)
Mutual labels:  lazy-loading, web-components, custom-elements
Ion Phaser
A web component to use Phaser Framework with Angular, React, Vue, etc 🎮
Stars: ✭ 152 (-34.2%)
Mutual labels:  web-components, custom-elements
Server Components
🔧 A simple, lightweight tool for composable HTML rendering in Node.js, based on web components.
Stars: ✭ 212 (-8.23%)
Mutual labels:  web-components, custom-elements
Markdown Toolbar Element
Markdown formatting buttons for text inputs.
Stars: ✭ 160 (-30.74%)
Mutual labels:  web-components, custom-elements
Preact Custom Element
Wrap your component up as a custom element
Stars: ✭ 212 (-8.23%)
Mutual labels:  web-components, custom-elements
Elm Canvas
A canvas drawing library for Elm
Stars: ✭ 124 (-46.32%)
Mutual labels:  web-components, custom-elements
Shadow Dom In Depth
Everything you need to know about Shadow DOM
Stars: ✭ 191 (-17.32%)
Mutual labels:  web-components, custom-elements
Dataformsjs
🌟 DataFormsJS 🌟 A minimal JavaScript Framework and standalone React and Web Components for rapid development of high quality websites and single page applications.
Stars: ✭ 95 (-58.87%)
Mutual labels:  web-components, custom-elements
Bolt
The Bolt Design System provides robust Twig and Web Component-powered UI components, reusable visual styles, and powerful tooling to help developers, designers, and content authors build, maintain, and scale best of class digital experiences.
Stars: ✭ 186 (-19.48%)
Mutual labels:  web-components, custom-elements
Time Elements
Web component extensions to the standard <time> element.
Stars: ✭ 2,318 (+903.46%)
Mutual labels:  web-components, custom-elements
Custom Elements
All about HTML Custom Elements
Stars: ✭ 188 (-18.61%)
Mutual labels:  web-components, custom-elements
Image Crop Element
A custom element for cropping a square image. Returns x, y, width, and height.
Stars: ✭ 115 (-50.22%)
Mutual labels:  web-components, custom-elements
Nutmeg
Build, test, and publish vanilla Web Components with a little spice
Stars: ✭ 111 (-51.95%)
Mutual labels:  web-components, custom-elements
Html Include Element
Easily include external HTML into your pages.
Stars: ✭ 143 (-38.1%)
Mutual labels:  web-components, custom-elements
Vanilla Hamburger
Animated hamburger menu icons for modern web apps (1.8 KB) 🍔
Stars: ✭ 110 (-52.38%)
Mutual labels:  web-components, custom-elements
Omi
Front End Cross-Frameworks Framework - 前端跨框架跨平台框架
Stars: ✭ 12,153 (+5161.04%)
Mutual labels:  web-components, custom-elements
Auto Check Element
An input element that validates its value with a server endpoint.
Stars: ✭ 85 (-63.2%)
Mutual labels:  web-components, custom-elements
Aybolit
Lightweight web components library built with LitElement.
Stars: ✭ 90 (-61.04%)
Mutual labels:  web-components, custom-elements
Swiss
🇨🇭Functional custom elements
Stars: ✭ 169 (-26.84%)
Mutual labels:  web-components, custom-elements
Clipboard Copy Element
Copy element text content or input values to the clipboard.
Stars: ✭ 198 (-14.29%)
Mutual labels:  web-components, custom-elements

<progressive-image> element

A progressive image element

CI status npm version npm downloads

Progressively enhance image placeholders once they are in the viewport.

  • Responsive lazy loading images
  • Save data option
  • No content reflow/layout shifting
  • No dependencies
  • Framework agnostic
progressive image element markup example

Install

$ npm install progressive-image-element

Usage

  1. Include the script & stylesheet within your application
<!-- Include the stylesheet, this could be direct from the package or CDN -->
<link rel="stylesheet" href="https://unpkg.com/[email protected]/dist/progressive-image-element.css" />

<!-- Include the custom element script, this could be direct from the package or CDN -->
<script src="https://unpkg.com/[email protected]/dist/index.js"></script>

or

// Import the custom element script
import ProgressiveImageElement from 'progressive-image-element';
  1. Use the <progressive-image> element markup
<progressive-image
  src="example-image-1x.jpg"
  srcset="example-image-2x.jpg 2x, example-image-1x.jpg 1x"
>
  <!-- Make sure to specify image dimensions -->
  <img src="placeholder-image.jpg" width="300" height="200" alt="Image" />
</progressive-image>

The placeholder image should be a solid color placeholder, LQIP or SQIP that hint at the content of the progressive image before it loads.

Attributes

  • src Specifies the image to display
  • srcset One or more image candidate strings
  • sizes Comma-separated list of source size descriptors
  • savedata Boolean attribute to load the images only after a click/tap on the placeholder image.
    By default enabled for slow connections (slow-2g|2g|3g).

Styling states

A CSS class loadable is present on <progressive-image> when the image is ready to load on user interaction (click). Used for slow connections or when the savedata attribute is present.

progressive-image.loadable { ... }

A CSS class [loading] is present on <progressive-image> while the image is loading.

progressive-image.loading { ... }

A CSS class .loaded is present on <img> children of <progressive-image> when the image was loaded.

progressive-image > img { opacity: 0; }
progressive-image > img.loaded { opacity: 1; }

Examples

Browser support

Browsers without native custom element support require a polyfill.

License

MIT © André Ruffert

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].