Skip to content

Test modulepreload in link header#34328

Merged
noamr merged 1 commit intomasterfrom
modulepreload-header
Jun 8, 2022
Merged

Test modulepreload in link header#34328
noamr merged 1 commit intomasterfrom
modulepreload-header

Conversation

@noamr
Copy link
Copy Markdown
Contributor

@noamr noamr commented Jun 7, 2022

No description provided.

const m = new URL('module1.js', location.href).toString();
const observer = new PerformanceObserver(l => {
const entries = l.getEntriesByName(m);
if (entries.length === 1) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

What if entries.length is more than 1, is that possible? And just for my knowledge here, it will always at least be one, is that right?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

It can theoretically be 2 if the module was preloaded, and importing it would not detect the preload and would re-fetch the module.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

But at this point we haven't even imported it. So how could it ever be 2 at this point?

const m = new URL('module1.js', location.href).toString();
const observer = new PerformanceObserver(l => {
const entries = l.getEntriesByName(m);
if (entries.length === 1) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

But at this point we haven't even imported it. So how could it ever be 2 at this point?

@noamr noamr merged commit 4b78bc1 into master Jun 8, 2022
@noamr noamr deleted the modulepreload-header branch June 8, 2022 12:35
Copy link
Copy Markdown

@Hyran15 Hyran15 left a comment

Choose a reason for hiding this comment

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

preload/link-header-modulepreload.html

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants