本文へスキップ
Skillpedia
WebサイトとUI(フロントエンド)75k · #3007

scheduler-yield

できること

このスキルは、ページを固まらせるおそれのある長いループや再帰的な処理を見つけ、ブラウザーが反応できるように中断を追加します。重い処理の間にページが止まって感じられる制作者向けです。

使う場面

  • ✓大量のデータを処理している間、ページが固まらないようにするようエージェントに頼むとき。
  • ✓アプリの重い処理の最中に、クリックや入力が遅く感じるとき。
  • ✓大きなループや大量のDOMの更新があるコードを確認し、操作の反応を保ちたいとき。

スキルのリンク

https://github.com/thedaviddias/Front-End-Checklist/blob/main/skills/scheduler-yield/SKILL.md

コピーしてAI(Claude、ChatGPT、Cursor)に貼り付け、指示に従うよう頼んでください。

使い方

いちばん簡単な方法:メッセージをコピーしてAIに貼り付けるだけ。AIがスキルを読んで指示に従います。

貼り付け用メッセージ

このスキルを使って手伝ってください:https://github.com/thedaviddias/Front-End-Checklist/blob/main/skills/scheduler-yield/SKILL.md このリンクのSKILL.mdファイルを読んで、私の作業でその指示に従ってください。
こういうスキルを、AIが自分で見つけてくれたら?無料のSkillpedia MCPをインストール。1行で、作業の前に15,000+のスキルから探してくれます。1分でインストール →

AIへの頼み方の例

“大きなリストを処理するとき、私のページが一瞬固まります。処理を分割して、ページが反応し続けるようにしてください。”

毎週5つの新しいスキル。1分で読めます。

仕組み

エージェントは、約50ミリ秒を超えて実行されうるループや一括の処理を見つけます。scheduler.yieldで塊の間に一時停止するようリファクタリングし、その関数が使えない場合のための代替も用意します。

技術的な内容(元のSKILL.md)

作者による元のテキスト(英語)をGitHubからそのまま表示しています。

Use scheduler.yield() to keep the main thread responsive during long tasks

Any JavaScript task longer than 50 ms blocks the browser's main thread, preventing it from processing clicks, keyboard events, and rendering frames. Yielding between chunks of work keeps Interaction to Next Paint (INP) low and makes the page feel responsive even during heavy computation.

Quick Reference

  • Tasks longer than 50 ms block input and hurt Interaction to Next Paint (INP)
  • scheduler.yield() pauses execution, lets the browser handle queued input, then resumes
  • Use a MessageChannel-based polyfill where scheduler.yield() is unavailable
  • Apply to data processing loops, tree traversals, and bulk DOM mutations

Check

Identify synchronous loops, recursive traversals, or bulk operations in this code that could run for more than 50 ms and block user input.

Fix

Refactor long synchronous tasks to yield to the browser between chunks using scheduler.yield() with a MessageChannel fallback.

Explain

Explain why tasks longer than 50 ms hurt INP, how scheduler.yield() works, and when to use it versus Web Workers.

Code Review

Review event handlers, data transformation functions, and initialization routines for synchronous loops over large collections that could block input. Flag any loop where the total work could exceed 50 ms.


For full implementation details, code examples, and framework-specific guidance, see references/rule.md.

Rule page: https://frontendchecklist.io/rules/javascript/scheduler-yield

よくある質問

なぜ50ミリ秒が重要なのですか?

このスキルによると、50ミリ秒を超える処理はメインスレッドをふさぎ、クリックや描画を遅らせることがあるからです。

代わりにWeb Workerを使うべきなのはいつですか?

このスキルは、scheduler.yieldとWeb Workerを比べることに触れています。Web Workerは処理をメインスレッドの外に移します。

これは反応の速さにどう影響しますか?

このスキルによると、Interaction to Next Paintを低く保ち、重い処理の間もページが速く感じられるよう助けます。

詳細

作者による元の説明

Use when reviewing JavaScript that performs synchronous loops over large datasets, recursive tree traversals, or bulk DOM updates that may exceed 50 ms on mid-range devices.

repo: thedaviddias/Front-End-Checklist

人気

GitHubのスター
75k
ランキング
#3007
ライセンス
MIT
更新日
2026/10/31

このスキルは役に立ちますか?

0

ログイン して投票しましょう。

コメント

  • …

このリポジトリの他のスキル

似ているスキル