https://github.com/AlStar01/lazy-loading-img
Web component to lazy load images using Intersection Observer
https://github.com/AlStar01/lazy-loading-img
stenciljs tsx typescript web-components
Last synced: over 1 year ago
JSON representation
Web component to lazy load images using Intersection Observer
- Host: GitHub
- URL: https://github.com/AlStar01/lazy-loading-img
- Owner: AlStar01
- License: mit
- Created: 2017-11-03T13:39:51.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2017-11-06T01:07:28.000Z (over 8 years ago)
- Last Synced: 2025-03-04T07:48:22.797Z (over 1 year ago)
- Topics: stenciljs, tsx, typescript, web-components
- Language: TypeScript
- Size: 104 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: LICENSE
Awesome Lists containing this project
README
# Lazy Loading Image
Web component to lazy load images using Intersection Observer.
## Getting Started
```bash
npm install
npm start
```
To watch for file changes during develop, run:
```bash
npm run dev
```
To build the component for production, run:
```bash
npm run build
```
To run the unit tests for the components, run:
```bash
npm test
```
## Using this component
### Polyfill
Not all browsers natively support [IntersectionObserver](https://caniuse.com/#search=IntersectionObserver). This can be supported with a polyfill such as [Polyfill.io](https://polyfill.io).
```html
```
### Script tag
- Put a script tag similar to this `` in the head of your index.html
- Then you can use the element anywhere in your template, JSX, html etc
### Node Modules
- Run `npm install lazy-loading-img --save`
- Put a script tag similar to this `` in the head of your index.html
- Then you can use the element anywhere in your template, JSX, html etc
### In a stencil-starter app
- Run `npm install lazy-loading-img --save`
- Add `{ name: 'lazy-loading-img' }` to your [collections](https://github.com/ionic-team/stencil-starter/blob/master/stencil.config.js#L5)
- Then you can use the element anywhere in your template, JSX, html etc
### HTML
```html
Lazy Loading Image Example
```

## Stencil
Stencil is a compiler for building fast web apps using Web Components.
Stencil combines the best concepts of the most popular frontend frameworks into a compile-time rather than run-time tool. Stencil takes TypeScript, JSX, a tiny virtual DOM layer, efficient one-way data binding, an asynchronous rendering pipeline (similar to React Fiber), and lazy-loading out of the box, and generates 100% standards-based Web Components that run in any browser supporting the Custom Elements v1 spec.
Stencil components are just Web Components, so they work in any major framework or with no framework at all.