Skip to content

A reactive notebook for Python — run reproducible experiments, query with SQL, execute as a script, deploy as an app, and version with git. Stored as pure Python. All in a modern, AI-native editor.

540 B
Raw Blame
/* Copyright 2026 Marimo. All rights reserved. */

/**
 * Schedule a callback to run when the browser is idle.
 *
 * @param callback - The callback to run when the browser is idle.
 */
export function onIdle(callback: () => void) {
  if ("scheduler" in window) {
    // oxlint-disable-next-line typescript/no-explicit-any
    (window as any).scheduler.postTask(callback, {
      priority: "background",
    });
  } else if ("requestIdleCallback" in window) {
    requestIdleCallback(callback);
  } else {
    setTimeout(callback, 0);
  }
}