zoukankan      html  css  js  c++  java
  • [Javascript] Use requestIdleCallback to schedule JavaScript tasks at an optimal time

    JavaScript is single-threaded, which can present some problems when creating an interactive user experience. If JavaScript runs too long while a user is attempting to interact with a page, it can cause noticeable jank or lag, which degrades the experience. requestIdleCallback is a DOM API that allows you to schedule a JavaScript function to be run when the page thread is idle, so your JavaScript doesn't get in the way of the user.

    let id = requestIdleCallback(
      () => {
        console.log("idle callback called");
      },
      { timeout: 2000 } // the function must be run within 2 seconds
    );
    
    cancelIdleCallback(id);
  • 相关阅读:
    servlet
    过滤器
    拦截器
    logback
    hibernate(1)
    函数的关键字参数
    函数的不定长参数
    打印星形三角
    九九乘法表
    udp客户端收发数据流程
  • 原文地址:https://www.cnblogs.com/Answer1215/p/11853163.html
Copyright © 2011-2022 走看看