Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/alsotang/ric.js


https://github.com/alsotang/ric.js

Last synced: 13 days ago
JSON representation

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;
});
```