Skip to content

Use fetchpriority=high for dynamically loaded scripts#2194

Open
bschwarzent wants to merge 1 commit into
releases/26.2from
features/bsh/26.2/462323_fetchpriority_high
Open

Use fetchpriority=high for dynamically loaded scripts#2194
bschwarzent wants to merge 1 commit into
releases/26.2from
features/bsh/26.2/462323_fetchpriority_high

Conversation

@bschwarzent
Copy link
Copy Markdown
Member

Modern browsers assign each request a priority. Scripts that are loaded dynamically by injecting an additional <script> tag into the DOM are assigned a low priority by default [1]. Under certain conditions, this will introduce significant but unnecessary delays (> 15s). This is problematic if the caller waits for the script completion.

Since request priorities are primarily relevant during the initial rendering of a HTML page, we can safely increase the priority hint for all scripts that are dynamically injected later using the central method $.injectScript() by setting the "fetchpriority" attribute [2] to "high".

[1] https://web.dev/articles/fetch-priority
[2] https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Attributes/fetchpriority

462323

Modern browsers assign each request a priority. Scripts that are loaded
dynamically by injecting an additional <script> tag into the DOM are
assigned a low priority by default [1]. Under certain conditions, this
will introduce significant but unnecessary delays (> 15s). This is
problematic if the caller waits for the script completion.

Since request priorities are primarily relevant during the initial
rendering of a HTML page, we can safely increase the priority hint for
all scripts that are dynamically injected later using the central method
$.injectScript() by setting the "fetchpriority" attribute [2] to "high".

[1] https://web.dev/articles/fetch-priority
[2] https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Attributes/fetchpriority

462323
@bschwarzent bschwarzent self-assigned this May 13, 2026
Copy link
Copy Markdown
Member

@paolobazzi paolobazzi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good to me

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants