Schedule callback to be called when the application is idle
npm i --save nativescript-idle

A NativeScript plugin that lets you to post a callback to be executed when the application is in relatively idle state. This can be used to schedule short-lived tasks that have to be executed on the main thread but are not critical and can be postponed for times when the user is not interacting with the application.

For example:

import { requestIdleFrame } from "nativescript-idle";

requestIdleFrame(() => {
var msg = "preloading " + route.path;
var start =;
// Task taking ~40ms.
var end =;
console.log(msg + " in " + (end - start))