All Projects → berwin → Time Slicing

berwin / Time Slicing

Licence: mit
Break down long tasks into smaller tasks, avoid blocking the main process.

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Time Slicing

karma-telemetry
Karma Framework for running performance tasks using Telemetry
Stars: ✭ 36 (-51.35%)
Mutual labels:  web-performance
Mozjpeg
Improved JPEG encoder.
Stars: ✭ 4,738 (+6302.7%)
Mutual labels:  web-performance
Pagespeed Score
DEPRECATED - use GoogleChrome/lighthouse-ci instead
Stars: ✭ 18 (-75.68%)
Mutual labels:  web-performance
Imager
Automated image compression for efficiently distributing images on the web.
Stars: ✭ 266 (+259.46%)
Mutual labels:  web-performance
Prerender.js
Fast webpages for all browsers.
Stars: ✭ 411 (+455.41%)
Mutual labels:  web-performance
V Lazy Image
Lazy load images using Intersection Observer, apply progressive rendering and css animations.
Stars: ✭ 563 (+660.81%)
Mutual labels:  web-performance
Website-Audit
It's an open-source report template that guides web professionals thought steps to audit any website in terms of the page speed and technical SEO optimisation.
Stars: ✭ 18 (-75.68%)
Mutual labels:  web-performance
Awesome Mobile Web Development
All that you need to create a great mobile web experience
Stars: ✭ 1,046 (+1313.51%)
Mutual labels:  web-performance
Garie
Open source web performance
Stars: ✭ 484 (+554.05%)
Mutual labels:  web-performance
Guess
🔮 Libraries & tools for enabling Machine Learning driven user-experiences on the web
Stars: ✭ 6,762 (+9037.84%)
Mutual labels:  web-performance
Skywalking
APM, Application Performance Monitoring System
Stars: ✭ 18,341 (+24685.14%)
Mutual labels:  web-performance
Perfjankie
Checking browser rendering performance regression
Stars: ✭ 343 (+363.51%)
Mutual labels:  web-performance
Kweb Core
A lightweight Kotlin web framework for backend developers 🦆
Stars: ✭ 567 (+666.22%)
Mutual labels:  web-performance
Pwa Fundamentals
👨‍🏫 Mike & Steve's Progressive Web Fundamentals Course
Stars: ✭ 256 (+245.95%)
Mutual labels:  web-performance
Browser Perf
Performance Metrics for Web Browsers
Stars: ✭ 930 (+1156.76%)
Mutual labels:  web-performance
qoopido.demand
Promise like module loader with automatic resolution of nested dependencies using XHR requests and localStorage caching to dynamically load modules, legacy JavaScript, CSS, text and bundles. Supports custom handler and plugins as well.
Stars: ✭ 36 (-51.35%)
Mutual labels:  web-performance
Guess Next
🔮 Demo application showing the integration of Guess.js with Next.js
Stars: ✭ 528 (+613.51%)
Mutual labels:  web-performance
Assassin
Assassin is a decentralized database that uses background threads to kill slow JavaScript.
Stars: ✭ 57 (-22.97%)
Mutual labels:  web-performance
Aurelia
Aurelia 2, a standards-based, front-end framework designed for high-performing, ambitious applications.
Stars: ✭ 995 (+1244.59%)
Mutual labels:  web-performance
Awesome Pagespeed Metrics
⚡Metrics to help understand page speed and user experience
Stars: ✭ 585 (+690.54%)
Mutual labels:  web-performance

time-slicing

Break down long tasks into smaller tasks, avoid blocking the main process.

Introduce

Usually synchronous code execution for more than 50 milliseconds is a long task.

Long tasks will block the main thread, causing the page to jam, We have two solutions, Web worker and Time slicing.

We should use web workers as much as possible, but the web worker cannot access the DOM. So we need to split a long task into small tasks and distribute them in the macrotask queue.

For example:

setTimeout(_ => {
  const start = performance.now()
  while (performance.now() - start < 1000) {}
  console.log('done!')
}, 5000)

The browser will get stuck for one second after the code is executed for five seconds.

We can use the chrome developer tool to capture the performance of the code run.

Now, we use time-slicing to cut long tasks, the code is as follows:

setTimeout(ts(function* () {
  const start = performance.now()
  while (performance.now() - start < 1000) {
    yield
  }
  console.log('done!')
}), 5000)

In the code, we use the yield keyword to split the code and distribute the code in different macrotask queues.

We can use the chrome developer tool to capture the performance of the code run.

From the figure we can see that the long task is gone, and replaced by a myriad of intensive small tasks.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].