• Stars
    star
    114
  • Rank 308,031 (Top 7 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created over 9 years ago
  • Updated about 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Lightweight, no dependency library for lazy image load. Duplicate element check, throttled scroll handler, percent threshold supported.

TADA

Lightweight, no dependency library for lazy image load.

Features

  • Uses IntersectionObserver API
  • Duplicate element check
  • Debounced event handler
  • Percentage threshold

Usage

Use data-src attribute for actual image. This attribute name can be changed by calling Tada.setup method. If that attribute is used in non <img> tag, image will be background image.

<img src="placeholder.png" data-src="original.png">

<div data-src="background.png"></div>
/* CSS selector */
Tada.add('ul img')

/* HTML element */
var img = document.createElement('img')
img.setAttribute('src', 'placeholder.png')
img.setAttribute('data-src', 'original.png')

Tada.add(img)

/* In jQuery */
$.fn.tada = function () {
  return this.each(function () {
    Tada.add(this)
  })
}

$('img').tada()

Settings

If you want to change default settings, call Tada.setup method before using Tada.add.

Tada.setup({
  attribute: 'data-src',
  delay: 50,
  threshold: '20%',
  callback: function (element) {
    console.log(element)
  }
})

Tada.add(element)

Options

name default unit description
attribute data-src attribute name for image url
delay 50 milliseconds delay for scroll event activation
threshold 20% % or px. px can be omitted margin for early loading
callback function(element) {} callback after image loaded.

Browser compatibility

Internet Explorer 9+ and other major browsers are supported.

More Repositories

1

dandy

โ€œ๋‹จ๋””โ€๋Š” ๋ถ€์‚ฐ๋Œ€ํ•™๊ต ์ธ๊ณต์ง€๋Šฅ์—ฐ๊ตฌ์‹ค๊ณผ (์ฃผ)๋‚˜๋ผ์ธํฌํ…Œํฌ๊ฐ€ ๊ณต๋™์œผ๋กœ ๋งŒ๋“ค์–ด http://speller.cs.pusan.ac.kr ํŽ˜์ด์ง€์—์„œ ์ œ๊ณตํ•˜๋Š” โ€œํ•œ๊ตญ์–ด ๋งž์ถค๋ฒ•/๋ฌธ๋ฒ• ๊ฒ€์‚ฌ๊ธฐโ€๋ฅผ ๋งฅ์—์„œ ์‰ฝ๊ฒŒ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๋„๋ก ํ•ด ์ฃผ๋Š” ๋„๊ตฌ์ž…๋‹ˆ๋‹ค. ๋งฅ์˜ ์˜คํ† ๋ฉ”์ดํ„ฐ๋ฅผ ์ด์šฉํ•ด์„œ ๋งฅ ์„œ๋น„์Šค ํ˜•ํƒœ๋กœ ์ œ์ž‘ํ–ˆ์Šต๋‹ˆ๋‹ค.
JavaScript
127
star
2

copy-url-for-alfred

You can copy browser's URL and title with various formats like markdown, anchor tag and your own.
JavaScript
121
star
3

applescript-applets

Collection of AppleScript applets.
57
star
4

vscode-dandy

ํ•œ๊ตญ์–ด ๋งž์ถค๋ฒ• ๊ฒ€์‚ฌ๊ธฐ for Visual Studio Code
JavaScript
41
star
5

reported-by

์ง€๊ธˆ ๋ณด๊ณ  ์žˆ๋Š” ๊ธฐ์‚ฌ๋ฅผ ์ž‘์„ฑํ•œ ๊ธฐ์ž์˜ ๋‹ค๋ฅธ ๊ธฐ์‚ฌ ๋ชฉ๋ก์„ ๋ณด์—ฌ์ฃผ๋Š” ํฌ๋กฌ ๋ธŒ๋ผ์šฐ์ €์˜ ํ™•์žฅ ํ”„๋กœ๊ทธ๋žจ
JavaScript
36
star
6

getting-started-webgl-with-threejs

Three.js๋กœ ์‹œ์ž‘ํ•˜๋Š” WebGL
JavaScript
17
star
7

threejs-lottery-wheel

Lottery Wheel with Three.js
JavaScript
10
star
8

open-with-sublime-text-2

Open with Sublime Text 2 in Finder, Path Finder.
10
star
9

neanthal

ํ•œ๊ธ€์„ ๋“œ๋ผ๋งˆ ์•„์Šค๋‹ฌ ์—ฐ๋Œ€๊ธฐ์— ๋‚˜์˜ค๋Š” ๋‡Œ์•ˆํƒˆ ์ข…์กฑ์˜ ์–ธ์–ด๋กœ ๋ณ€ํ™˜
JavaScript
9
star
10

copy-path-in-finder

Applet for Finder
JavaScript
9
star
11

wormhole

Copy text from A, paste to B automatically
JavaScript
8
star
12

chrome-extensions

๋ธ”๋กœ๊ทธ์— ์—ฐ์žฌํ•˜๋Š” ๊ธ€์˜ ์˜ˆ์ œ๋ฅผ ๋น„๋กฏํ•œ ๊ตฌ๊ธ€ ํฌ๋กฌ ํ™•์žฅ ํ”„๋กœ๊ทธ๋žจ์„ ์˜ฌ๋ฆฝ๋‹ˆ๋‹ค.
JavaScript
6
star
13

chrome-fuzzy-filter

Find keyword in the list quickly with less typing
JavaScript
5
star
14

webpack-skeleton

Webpack Skeleton for JavaScript Library Development
JavaScript
5
star
15

chrome-picture-in-picture

Picture-in-Picture extension for video in Google Chrome
JavaScript
4
star
16

z.js

Better DOM element builder inspired by zen-coding
JavaScript
4
star
17

jamo

ํ•œ๊ธ€ ์ฒซ๊ฐ€๋/ํ˜ธํ™˜์„ฑ ์ž/๋ชจ์Œ์˜ ์กฐํ•ฉ/๋ถ„ํ•ด๋ฅผ ์œ„ํ•œ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ
JavaScript
3
star
18

tumblr_themes

JavaScript
2
star
19

sandstorage

Web Storage manager supporting expiration time
JavaScript
2
star
20

chrome-band-member-exporter

๋ฐด๋“œ ์„œ๋น„์Šค์—์„œ ๋ฉค๋ฒ„ ๋ชฉ๋ก์„ CSV, JSON, TSV ๋“ฑ์˜ ํŒŒ์ผ๋กœ ๋‚ด๋ ค๋ฐ›๋Š” ๊ตฌ๊ธ€ ํฌ๋กฌ ํ™•์žฅ ํ”„๋กœ๊ทธ๋žจ
JavaScript
1
star
21

stylist

Dynamic CSS rule manager
JavaScript
1
star
22

ttlize

Timeout based memoization supporting Web Storage
JavaScript
1
star
23

intersectionobserver-examples

HTML
1
star
24

fallroot.github.com

JavaScript
1
star