Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

link instead of script? #8

Closed
bmeck opened this issue Mar 15, 2018 · 11 comments
Closed

link instead of script? #8

bmeck opened this issue Mar 15, 2018 · 11 comments

Comments

@bmeck
Copy link

bmeck commented Mar 15, 2018

Is there a specific reason for the use of <script> instead of <link>? The only reason I can think of is the HTTP Header support that comes with <link>, but am unsure what is problematic about that.

@matthewp
Copy link

matthewp commented Mar 15, 2018

With <link> you couldn't inline the map in the HTML. You could put it in a header but many servers have size limits on headers that the package map might exceed.

@matthewp
Copy link

I take that back, looks like the typical size limit is 8k, I doubt a packagemap would exceed that. I had thought the limit was smaller.

@bmeck
Copy link
Author

bmeck commented Mar 15, 2018

@matthewp if the link header is mostly a href I don't think it likely to exceed the size limits. Per inlining into the document, I'm not sure if a precomputed workflow like this is as desirable to output back into inline HTML for most situations. If desirable to inline we could certainly support both ways to load things, similar to CSS.

I somewhat still question if inlining is going to be more desirable than linking since you will be doing many resource requests most likely as the README states. Inlining can help with initial load, but could cause fewer cache hits on the initial document load if the package name map changes over time. In particular, being unable to load updated package name maps after initial load means that any changes would require a refresh in order to be synced up. Hopefully, we can find a workflow where package name maps change rarely; I am unsure of that being realistic.

@matthewp
Copy link

Good point about cache hits. For a lot (but not all) sites, caching isn't used on documents as they tend to be dynamic. I'm concerned about using hrefs with http/1.1 servers though. The packagemap is a super-dependency of all modules, so it will block the preload scanner from doing its job.

@justinfagnani
Copy link
Collaborator

We considered both, but started with <script> because of inlining, and not wanting to have two ways to do the same thing.

@matthewp
Copy link

@justinfagnani I'm curious about this:

Adding a second <script type="packagemap"> has no effect.

Should we be concerned that a large packagemap will block scripts from loading? One case where you might want multiple packagemaps would be if you wanted to put essential, above-the-fold scripts into its own tree and then defer the rest for later. For example:

<script type="packagemap">
  [ESSENTIAL MAPPING HERE]
</script>
<script type="module" src="./main.js"></script>

<main> ... </main>

<script type="packagemap">
  [NON-ESSENTIAL MAPPING HERE]
</script>
<script type="module" src="./less-important.js"></script>

The question being whether a packagemap is ever big enough where splitting would be desired. I understand that allowing multiple maps starts to raise conflict resolution problems...

@justinfagnani
Copy link
Collaborator

I hope that can be explored more, and my team has asked for it. I understand that there might be blockers, but maybe there's some way to figure it out.

@justinfagnani
Copy link
Collaborator

btw, this is a dupe of #1

@domenic
Copy link
Collaborator

domenic commented Mar 15, 2018

Hmm, I really tried to pre-empt this by pre-filing #1. Let's please continue discussion there? Some good points have been raised so far though!

@domenic domenic closed this as completed Mar 15, 2018
@bmeck
Copy link
Author

bmeck commented Mar 15, 2018

@domenic I'm not sure this fits in either #1 or #2 since the link: header could apply to both.

@domenic
Copy link
Collaborator

domenic commented Mar 15, 2018

Well, I agree the issues slightly bleed over, but since #1 is where <script> is the existing proposal, we'd need to establish that link is good enough or better for the window context before considering it for the worker context.

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

No branches or pull requests

4 participants