Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

hx-preload (htmx 4): an expired preload blocks re-preloading until the element is clicked

オープン 初心者向け
#4,151 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 4 日以内に返信

まだ誰も着手していません。

評価

難易度
1/5
見積もり時間
1時間未満
初心者へのやさしさ
88/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
javascript
領域
frontend

調査の方向性

issue では、four ブランチの src/ext/hx-preload.js と、elt._htmx?.preload をチェックする早期リターンが示されています。まず、その preload リスナーと htmx_before_request の有効期限処理を読んでください。要素にマウスを合わせ、5秒以上待ってから、もう一度マウスを合わせて再現します。前の preload の期限切れ後、次にマウスを合わせたときに新しい preload が開始されれば完了です。

索引モデルが issue の本文から書いたものです。

説明

Version: htmx 4.0.0 (dist/ext/hx-preload.js; also current on the four branch, src/ext/hx-preload.js)

What happens

The preload listener returns early whenever a preload is stored on the element, without checking whether it has expired:

if (elt._htmx?.preload) return;

An expired entry is only removed in htmx_before_request, i.e. by the next real request. So once the preload window has passed (5 s by default), hovering the element never preloads again until it has been clicked once.

Repro

<button hx-get="/page" hx-target="#main" hx-preload="mouseover">Page</button>
  1. Hover the button: a preload request is made. ✅
  2. Wait more than 5 s without clicking.
  3. Hover again: no request. ❌ (expected: a new preload)
  4. Click: a normal request is made (the expired preload is discarded).
  5. Hover again: preload fires again.

Expected

An expired preload should be replaced on the next trigger, as expiresAt suggests (htmx_before_request already ignores an expired preload).

Suggested fix

if (elt._htmx?.preload && Date.now() < elt._htmx.preload.expiresAt) return;

(Optionally also delete elt._htmx.preload before starting the new prefetch.)

主要言語
JavaScript
スター
49.6k
フォーク
1.7k
平均マージ
10日 5時間
マージ済み PR(30日)
9

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

bigskysoftware/htmx のほかの issue

bigskysoftware/htmx の issue をすべて見る

似ている issue

JavaScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。