Skip to content
This repository has been archived by the owner on Feb 28, 2022. It is now read-only.

Generate Link header with as attribute. #520

Closed
stefan-guggisberg opened this issue Nov 7, 2019 · 6 comments
Closed

Generate Link header with as attribute. #520

stefan-guggisberg opened this issue Nov 7, 2019 · 6 comments
Assignees
Labels
enhancement New feature or request

Comments

@stefan-guggisberg
Copy link
Contributor

A Link response header is automatically generated from <link /> tags (see #122). However, only href and rel attributes are handled. The as attribute is ignored.

See:
https://www.w3.org/TR/preload/#as-attribute
https://html.spec.whatwg.org/multipage/semantics.html#attr-link-as

@stefan-guggisberg stefan-guggisberg self-assigned this Nov 7, 2019
@stefan-guggisberg stefan-guggisberg added the enhancement New feature or request label Nov 7, 2019
@stefan-guggisberg
Copy link
Contributor Author

stefan-guggisberg commented Nov 8, 2019

Further investigation revealed:

  • The preload keyword used in link elements is W3C Candidate Recommendation from 26 June 2019 and work in progress: https://www.w3.org/TR/preload
  • JSDOM does not yet support the as attribute specified in above document.

I suggest we wait until JSDOM supports the additional link attributes. As a workaround we probably could use something like <meta http-equiv="Link" content="</some.jpeg>; rel=preload; as=image" />

@trieloff
Copy link
Contributor

Or we could have a mapping

  • link rel=stylesheet = as=style
  • img = as=image
  • script src = as=script
  • script type=module = as=script

and so on: https://www.w3.org/TR/preload/#as-attribute

@stefan-guggisberg
Copy link
Contributor Author

Or we could have a mapping

good point. but then we loose control what we want to push. automagic vs explicit, I lean towards explicit.

@trieloff
Copy link
Contributor

Is there a JSDOM issue for the as attribute? Maybe the fastest path to getting proper support is a PR and we would benefit from having that relationship with the JSDOM team anyway.

@stefan-guggisberg
Copy link
Contributor Author

stefan-guggisberg commented Nov 16, 2019

Is there a JSDOM issue for the as attribute?

jsdom/jsdom#2471

stefan-guggisberg added a commit that referenced this issue Jul 1, 2020
* feat(add-headers): support meta http-equiv Link tag

#520

* test(testhtmlproduction): fix X-ESI test failure, skip test for 'as' attribute

* fix(add-headers): thanks, lgtm!

* docs: added link to JSDOM issue

* test: fixed tests

* test: code coverage

* chore(docs): updating documentation [skip ci]

Co-authored-by: CircleCi Build <circleci@example.com>
Co-authored-by: Tobias Bocanegra <tripodsan@users.noreply.github.com>
@stefan-guggisberg stefan-guggisberg self-assigned this Jul 1, 2020
@stefan-guggisberg
Copy link
Contributor Author

With the changes in ad22823 the as attribute will be handled once JSDOM supports it.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants