テーマ: browser
-
ブラウザーストレージ:cookie、Web Storage、IndexedDB の比較
Cookie はリクエストごとに送られ、仕様上の容量は小さい。localStorage と sessionStorage はオリジンごとに数 MiB の同期的な文字列ストアで、IndexedDB は非同期かつトランザクション対応で、オリジンの大きな共通枠を使う。永続化が認められない限り、ブラウザーの保存はベストエフォートであり、オリジンごとに区切られる。
-
同一オリジンポリシー:オリジンの定義と隔離する対象
オリジンは URL のスキーム、ホスト、ポートからなる。スクリプトは同一オリジンの文書、ストレージ、応答を読み書きできる。別オリジンからの読み取りは既定で拒否されるが、フォーム送信などの書き込みや、画像・スクリプトの埋め込みは通常許可される。CORS は読み取り制限を緩めるが、CSRF 対策は引き続き必要である。
-
Using fetch with timeouts and AbortController
A fetch promise rejects only on network failure, not on HTTP error status, and it has no timeout by itself. Pass an AbortSignal combined from AbortSignal.timeout and a caller's controller, check response.ok, and tell TimeoutError, AbortError, network errors and HTTP errors apart in the catch.
-
Web Vitals:LCP、INP、CLSが測るもの
Core Web Vitalsは3つの実ユーザー指標です。Largest Contentful Paintは最大の可視要素の描画時間で目標2.5秒、Interaction to Next Paintは最長の操作遅延で目標200ミリ秒、Cumulative Layout Shiftは予期しない移動で目標0.1です。それぞれページ読み込みの75パーセンタイルで評価します。
-
Web Push basics: subscriptions, VAPID keys and the push service
A browser subscribes with its vendor's push service and hands the page an endpoint plus keys; the application server POSTs encrypted messages to that endpoint with a TTL header and a VAPID JWT (ES256, aud = push service origin, exp at most 24 hours) whose public key was passed to PushManager.subscribe as applicationServerKey. A 201 means accepted, not delivered.
-
ブラウザーの E2E テストで安定したセレクターと自動待機を使う
不安定なブラウザーテストの主因は、壊れたり別の要素を選んだりするセレクターと、タイミングを決め付ける固定待機です。ロール、ラベル、テスト ID で探し、各ロケーターを一つの要素に一致させ、時間ではなく再試行するアサーションと操作可能性の確認で同期します。
-
CSS レイアウト:flexbox と grid の使い分け
Flexbox は行または列に沿って空間を配分する一次元モデルで、grid は行と列を同時に定義する二次元モデルです。内容に応じたグループには flexbox、ページやフォームの構造には grid を使い、両者を組み合わせます。gap を使い、要素を縮小できるようにしてテキストのはみ出しを防ぎます。
-
When does progressive enhancement pay off for an application that needs JavaScript anyway?
Open question: for applications whose core features cannot work without script, which parts still deserve a working no-script or reduced-script path, how often does script fail to run for a real audience, and how should a team decide with data rather than principle?
-
The JavaScript event loop: tasks, microtasks and rendering
JavaScript runs one job at a time; the HTML event loop takes a task, then drains the whole microtask queue (promise reactions, queueMicrotask) before the next task or a rendering opportunity. Long synchronous work and endless microtask chains block input and painting.
機械可読: JSON