Skip to content

Link header processing not defined #4224

Closed

Description

@domfarolino

Processing Link headers states "These headers are to be processed according to the rules given in the relevant specifications" and that "Registration of relation types in HTTP Link headers is distinct from HTML link types, and thus their semantics can be different from same-named HTML types".

However, Web Linking states "It is semantically equivalent to the <LINK> element in HTML", so it seems that the specs are sort of pointing at each other. Since Web Linking claims they are semantically equivalent to the <LINK> element, we should at least point to the obtain the resource in HTML. I imagine to be more formal maybe should define a collection of the given Link headers that we can "obtain" before parsing the document?

Furthermore there are some processing bits that are relevant for Link headers that are not necessarily a concern for normal <link> processing. Generally Link headers can be fetched immediately, however some headers require viewport information that might not be available when the headers arrive (and would otherwise be fetched):

  • Link headers with media attribute
    • media attribute helps determine whether a rel=stylesheet is script-blocking or not
    • also for rel=preloads it determines whether or not the resource should be obtained
  • Link headers with imagesrcset and imagesizes attributes (/cc @irori @kinu ran into this when implementing also cc @yoavweiss )

Implementers will need to defer the fetching of these Link headers until the viewport info is available (Chrome waits until the first chunk of the document is parsed IIUC) so I think it might be nice to indicate this in the spec in some way.

Activity

  1. annevk commented on Dec 10, 2018

    @annevk
    Member

    I think Firefox waits as well, which for rel=stylesheet (which I'm not sure other browsers support) is important due to quirks mode et al.

  2. yoavweiss commented on Dec 24, 2018

    @yoavweiss
    Contributor

    Implementers will need to defer the fetching of these Link headers until the viewport info is available (Chrome waits until the first chunk of the document is parsed IIUC)

    AFAIK, the same is true for WebKit as well.

    so I think it might be nice to indicate this in the spec in some way.

    Agreed. At the same time, I think Chrome currently performs some optimizations that WebKit does not, so we need to spec language to allow for that.

  3. domfarolino commented on Jan 10, 2019

    @domfarolino
    MemberAuthor

    As Anne pointed out elsewhere, https://drafts.csswg.org/cssom/#requirements-on-user-agents-implementing-the-http-link-header seems worth looking into more, though it is relatively incomplete at the time of writing this. (Just making note of it here).

  4. domfarolino commented on Jun 10, 2020

    @domfarolino
    MemberAuthor

    As per https://bugs.chromium.org/p/chromium/issues/detail?id=19237, Chrome is not interested in implementing the Link rel=stylesheet headers, and I believe Firefox is the only browser that implements this feature. Should we consider removing this from the spec? I guess that would entail changing the CSSWG draft mentioned above, as well as mentioning in this spec that the stylesheet relation is not supported by the Link header.

    What do people think about this?

  5. domenic commented on Jun 10, 2020

    @domenic
    Member

    I agree that if this is only supported by one implementer then it should be removed from the spec.

    I guess Chrome does support Link for other rels though, e.g. preload. So fully closing this issue would involve specifying the processing model for those.

    Here's one idea for a plan:

  6. awwright commented on Jun 10, 2020

    @awwright

    I would like to see support for the Link header, I think this belongs in Web browsers. But I'm struggling to see how this is an HTML issue; especially since one of the use-cases is styling non-HTML media types (which is supported by CSS). So I think this should be factored out of HTML.

    Web browsers should be able to process a Link from multiple sources—an HTML <link> header being the most common, but the Link header too; and they should process it the same way.

  7. annevk commented on Jun 11, 2020

    @annevk
    Member

    The HTML Standard defines page load for all web browser resource types, not just HTML. See the section "Browsing the Web".

  8. awwright commented on Jun 12, 2020

    @awwright

    @annevk That should be factored out. HTML has no business being the Web Browser Specification(TM)

  9. domfarolino commented on Jun 12, 2020

    @domfarolino
    MemberAuthor

    Says who?

  10. awwright commented on Jun 12, 2020

    @awwright

    @domfarolino In short, RFC 6838; I opened #5639 to provide more details.

  11. yoavweiss commented on Jun 12, 2020

    @yoavweiss
    Contributor

    @awwright - I doubt you'd have much success in convincing the HTML spec editors and browsers to modify how browsers' processing model is defined.

    Specifically for Link headers, if we were to properly define support for stylesheets, we would need to define how they interact with the cascade and in-document stylesheets. That definition needs to live in HTML.

    Link header support for stylesheets also introduces complications in case there are more than one header, as HTTP intermediaries can change the order of headers. That's contrary to the HTTP specification, but never the less is something I've seen happening, so I'd be highly reluctant to introduce content reliance on proxies doing the right thing, as in those cases applying those styles can result in different applicable styles based on e.g. which cache the page went through.

    At the same time, on the issue that's been open for the last 11 years, I haven't heard any strong use-cases as to why this is something that the web needs.

    If you have clear & strong use-cases for Link header application of stylesheets, I'm more than willing to hear them.
    The only use-case I heard so far is application of styles to image documents.
    Theoretically we could support:

    • Application of Link styles only to image documents
    • Assuming there's a single Link header, to avoid potential cascade issues

    It would still be something that requires implementer interest in order to add such support in Chromium or WebKit. I'm not aware of such interest.

  12. j9t commented on Jun 14, 2020

    @j9t
    Contributor

    I’m in favor of this feature and keeping it in the specification: It’s amazing to make websites simpler and more maintainable and may just have received too little attention. (Which was certainly due to lack of support, but is generally not the first and only time this has happened.)

    How can outside developers best make and support the case? I suppose the most effective way was to somehow convince another vendor to implement the header (those here involved with Chrome, what would tip the scale?), but do you see additional options that could also help?

    PS.
    I’d have some thoughts about some of the concerns (@yoavweiss), though these definitely include authors making a conscious choice, weighing pros and cons of each approach.

  13. yoavweiss commented on Jun 14, 2020

    @yoavweiss
    Contributor

    I’m in favor of this feature and keeping it in the specification: It’s amazing to make websites simpler and more maintainable

    Could you please elaborate on how this feature would do that? What would it enable you to do that is not possible today?

    those here involved with Chrome, what would tip the scale?

    An actual strong use-case that this feature would enable would be a good start.

  14. 5 remaining items

  15. j9t commented on Jun 15, 2020

    @j9t
    Contributor

    It’s amazing to make websites simpler and more maintainable

    Could you please elaborate on how this feature would do that? What would it enable you to do that is not possible today?

    An actual strong use-case that this feature would enable would be a good start.

    I think Link’s unique strength is that it does away with markup for styling purposes. Every other approach requires special markup.

    The main benefit seems to be ease of maintenance of CSS references. To an extent, that easier maintenance is even automatically enforced (because several types of such updates would need to happen by changing the Link header).

    Its main use case, in my eyes, are large collections of documents, meaning large content sites.

    Now, these points can certainly be attacked (HTML payload decreases but HTTP header payload increases, or a single style sheet ref in a single server config being no improvement to a single style sheet ref in a single site template). Still, overall Link does come with unique advantages that would be great to be available for use in practice.

    —A frank side note: I’m biased because a huge fan of this option. I love HTML code like the one in https://hell.meiert.org/temp/link/ (just some fooling around—obviously, use Firefox for styling), where all code except for the doctype relates to structure, as pure as one might wish HTML to be. However, I also realize how our field has changed a lot, so that I wouldn’t bet on broad adoption even when there was broad support. Still—for HTML optimization, in my mind, it’s a fantastic feature, and I keep seeing use cases for it.

  16. goodevilgenius commented on Sep 9, 2021

    @goodevilgenius

    The only use-case I heard so far is application of styles to image documents.

    It actually applies to most non-HTML documents renderable by the browser: images, video, audio, plain text, PDFs. All of these could be styled through CSS within the browser using a Link header.

    If I link to an MP4, it will play in the browser inside an implied <video> tag, which can be styled, e.g.

  17. noamr commented on Feb 15, 2022

    @noamr
    Contributor

    I suggest to start with spec'ing the currently implemented common denominator - preload links that get loaded in two phases - when the document is initialized if they're not viewport dependant, after the first chunk if they are.
    I can work on a PR for this.

    Once this is in place, we can incrementally and optionally add more things:

    • Link headers in subresources
    • Link headers in workers
    • preconnect (which is not yet 100% spec'ed)
    • prefetch (requires spec'ing prefetch first regardless of header)
    • early hints
    • Consider additional link types, such as stylesheet as per this issue, given additional implementor interest.
  18. added a commit that references this issue on Feb 28, 2022
  19. added a commit that references this issue on Mar 8, 2022
  20. added a commit that references this issue on Jun 3, 2022
  21. domenic commented on Jan 18, 2023

    @domenic
    Member

    @noamr, do you think there's anything left for this? Maybe only things that are tracked in other issues?

    We could spin off a separate "implementer interest needed" issue for tracking rel=stylesheet support, in particular.

  22. noamr commented on Jan 18, 2023

    @noamr
    Contributor

    @noamr, do you think there's anything left for this? Maybe only things that are tracked in other issues?

    We could spin off a separate "implementer interest needed" issue for tracking rel=stylesheet support, in particular.

    Yes sounds good
    Also we have other open PRs for subresource link headers (which I'm still not sure is a good feature...)

  23. added a commit that references this issue on Jan 18, 2023
    b6964e3
  24. added a commit that references this issue on Jan 19, 2023
    0ea88cf
  25. added a commit that references this issue on Jan 25, 2023
    3fae597
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions