Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/alsotang/ric.js
https://github.com/alsotang/ric.js
Last synced: 13 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/alsotang/ric.js
- Owner: alsotang
- Created: 2015-09-30T17:05:00.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2015-10-14T13:56:55.000Z (about 9 years ago)
- Last Synced: 2024-11-03T17:05:05.477Z (2 months ago)
- Language: HTML
- Size: 141 KB
- Stars: 2
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## intro
**[requestIdleCallback](https://developers.google.com/web/updates/2015/08/27/using-requestidlecallback)** experiment
Execute heavy computing work, but do not block the browser.
## example
without `ric`, and block
```js
var max = 1000000000;
var count = 0;
while (count < max) {
count++;
}document.querySelector('.result').innerHTML = count;
```with `ric`, and not block
```js
var max = 1000000000;
var count = 0;ric(function heavyWork() {
count++
if (count % 1000000 === 0) {
console.log('count is ' + count);
}
}, function isDone() {
return count >= max;
}, function afterDone() {
document.querySelector('.result').innerHTML = count;
});
```