All Projects → snewcomer → raf-pool

snewcomer / raf-pool

Licence: other
requestAnimationFrame pool to avoid busyness on the thread

Programming Languages

typescript
32286 projects
javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to raf-pool

rocket-lazy-load
Standalone LazyLoad plugin for WordPress (based on WP Rocket)
Stars: ✭ 25 (+56.25%)
Mutual labels:  lazyload, lazyload-images
guide-to-async-components
📖 Guide To JavaScript Async Components
Stars: ✭ 79 (+393.75%)
Mutual labels:  lazyload, lazyload-images
lazysimon
Minimal effort 350 byte JavaScript library to lazy load all <img> on your website
Stars: ✭ 18 (+12.5%)
Mutual labels:  lazyload, lazyload-images
jekyll-loading-lazy
🧙🏽‍♀️ Automatically adds loading="lazy" to <img> and <iframe> tags. Load images on your sites lazily without JavaScript.
Stars: ✭ 41 (+156.25%)
Mutual labels:  lazyload, lazyload-images
ngx-progressive-image-loader
lazy load img/picture, prevent reflow and seo friendly.
Stars: ✭ 35 (+118.75%)
Mutual labels:  lazyload, lazyload-images
magento2-catalog-lazy-load
Improve the load time of your Magento 2 categories pages by loading your images on demand with our Lazy Load Extension
Stars: ✭ 56 (+250%)
Mutual labels:  lazyload, lazyload-images
lazyload-vue
Vue Plugin for vanilla-lazyload
Stars: ✭ 29 (+81.25%)
Mutual labels:  lazyload, lazyload-images
Vanilla Lazyload
LazyLoad is a lightweight, flexible script that speeds up your website by deferring the loading of your below-the-fold images, backgrounds, videos, iframes and scripts to when they will enter the viewport. Written in plain "vanilla" JavaScript, it leverages IntersectionObserver, supports responsive images and enables native lazy loading.
Stars: ✭ 6,596 (+41125%)
Mutual labels:  lazyload, lazyload-images
lazy-load-images.js
Progressive & lazy loading images.
Stars: ✭ 17 (+6.25%)
Mutual labels:  lazyload, lazyload-images
Ng In Viewport
Allows us to check if an element is within the browsers visual viewport
Stars: ✭ 178 (+1012.5%)
Mutual labels:  lazyload
Lazysizes
High performance and SEO friendly lazy loader for images (responsive and normal), iframes and more, that detects any visibility changes triggered through user interaction, CSS or JavaScript without configuration.
Stars: ✭ 15,716 (+98125%)
Mutual labels:  lazyload
Defer.js
🥇 A super small, super efficient library that helps you lazy load everything like images, video, audio, iframe as well as stylesheets, and JavaScript.
Stars: ✭ 138 (+762.5%)
Mutual labels:  lazyload
React In Viewport
Detect if React component is in viewport
Stars: ✭ 183 (+1043.75%)
Mutual labels:  lazyload
angular-webpack-material-lazyload-typescript-starter-template
Angular starter template using typescript, angular-material, ui-router, oclazyload with webpack support.
Stars: ✭ 55 (+243.75%)
Mutual labels:  lazyload
Douban Movie
🎥The douban-movie Application built with webpack + vue + vuex + vue-router + iView.
Stars: ✭ 147 (+818.75%)
Mutual labels:  lazyload
any-scroll
🚀 模拟scrollview, 支持pc/移动端, 让实现Tab/Slider等组件轻而易举.
Stars: ✭ 45 (+181.25%)
Mutual labels:  requestanimationframe
React Lazy
Universal lazy loader components using IntersectionObserver for React
Stars: ✭ 118 (+637.5%)
Mutual labels:  lazyload
Vue Lazyload Img
A plugin of vue for image lazyload(vue图片懒加载插件)
Stars: ✭ 250 (+1462.5%)
Mutual labels:  lazyload
Androidxlazyload
😈😈Fragment lazy loading under the androix
Stars: ✭ 110 (+587.5%)
Mutual labels:  lazyload
Oclazyload
Lazy load modules & components in AngularJS
Stars: ✭ 2,661 (+16531.25%)
Mutual labels:  lazyload

raf-pool

requestAnimationFrame pool to avoid busyness on the thread

Download count all time npm version

Dependency Status devDependency Status

Why use an administrator to manage all the elements on my page?

This library is used in ember-in-viewport and ember-infinity.

window.requestAnimationFrame schedules and performs an animation before the next repaint, thus taking the guesswork out of being in sync with the user's browser readiness. It will perform the callback function 60 times per second, thus making the main thread quite busy. If you have hundreds of images on the page, it can be very painful on memory when you have hundreds of recurring handles on requestAnimationFrame. This small library can dramatically reduce memory usage as it uses a single requestAnimationFrame.

While observing 20 images on a page:

Normal

With raf-pool

Installation

npm install raf-pool --save

Usage

API

  1. elementId: DOM Node identifier
  2. callbackFn
    • callback function to perform logic in your own application
    • Note, your callback function should add back the method to the raf-pool service.
import RafPool from 'raf-pool';

const rafPool = new RafPool();

const callback = () => {
  rafPool.add(element.id, callback);
};

callback();

Methods

// add an element to static administrator
rafPool.add(element.id, callback);

// Use in cleanup lifecycle hooks (if applicable) from the element being observed
rafPool.remove(element.id);

// Use in cleanup lifecycle hooks of your application as a whole
// This will remove the in memory data store holding onto all of the observers
rafPool.reset();
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].