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

Draft a page on polyfills #38326

Merged
merged 7 commits into from
Mar 4, 2025
Merged

Draft a page on polyfills #38326

merged 7 commits into from
Mar 4, 2025

Conversation

wbamberg
Copy link
Collaborator

@wbamberg wbamberg commented Feb 25, 2025

...as promised in https://github.com/orgs/mdn/discussions/475#discussioncomment-11790206.

I haven't suggested we have a defined "Polyfills" section in reference pages (although I think we should). That seems like a thing we could deal with separately. I also talk a bit about Web/API, since we do link to polyfills there sometimes, too.

@wbamberg wbamberg requested a review from a team as a code owner February 25, 2025 18:40
@wbamberg wbamberg requested review from hamishwillee and removed request for a team February 25, 2025 18:40
@github-actions github-actions bot added Content:Meta Content in the meta docs size/s [PR only] 6-50 LoC changed labels Feb 25, 2025
Copy link
Contributor

github-actions bot commented Feb 25, 2025

Preview URLs

External URLs (5)

URL: /en-US/docs/MDN/Writing_guidelines/Page_structures/Polyfills
Title: Polyfills

(comment last updated: 2025-03-04 00:05:26)

- Conformance to the specification for the feature for which they are providing an implementation.
- Adoption by the web development community, as seen in metrics such as the number of [npm](https://www.npmjs.com/) downloads.

Anyone can propose that MDN should recognize an additional source of polyfills by [filing an issue in the mdn/content repository](https://github.com/mdn/content/issues). However, the MDN maintainers expect the number of recognized polyfills linked from MDN to remain very small, to reduce the risk of recommending polyfills that cause problems for web developers.
Copy link
Member

Choose a reason for hiding this comment

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

I recommend sending issues in mdn/mdn, or mdn/mdn-community, since it rarely only concerns one or a few pages.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

You mean, start a discussion in https://github.com/orgs/mdn/discussions? mdn-community doesn't seem to support issues. I would be happy to say that instead.

Copy link
Member

Choose a reason for hiding this comment

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

Oh yeah, a discussion in mdn-community or an issue in mdn/mdn is what I meant.


### Integration of polyfills into pages

When a page in the JavaScript reference documentation links to a polyfill, it adds the link in the "See also" section at the end of the page.
Copy link
Member

Choose a reason for hiding this comment

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

You can even copy the exact wording we use:

- [Polyfill for `featureName` in `project-name`](link)

And mention that they should be at the top of the list


### Selected polyfills

The [Web API reference documentation](/en-US/docs/Web/API) can link to polyfills that are maintained alongside the specification for the feature itself.
Copy link
Member

Choose a reason for hiding this comment

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

This seems a little vague. Maybe a few examples would help.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Hm, well for example the repo that hosts the trusted types specification includes a polyfill: https://github.com/w3c/trusted-types?tab=readme-ov-file#polyfill. Is it enough to add that as an example or do we need to come up with some general form of words for it? "maintained in the same repo as the spec" seems a bit restrictive?

Copy link
Member

Choose a reason for hiding this comment

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

Maybe "maintained by the spec champions"? "Officially endorsed"? I'm not sure how blessed that polyfill is; I just know that TC39 is very cautious not to endorse any polyfill, even one developed by the champions themselves. But in any case yes a link to that page is what I'm looking for at the minimum.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Maybe "maintained by the spec champions"? "Officially endorsed"?

But (if we're going to be picky) these also seem vague. Who are the spec champions, and do we know that they maintain it, or just that they trust the people who do. And what does official endorsement look like? I mean in the TT case, I'm pretty sure I want MDN to link to it, and I'm pretty sure I trust it, because it's in the same repo as the spec, and I would assume that the maintainers keep that repo under control. I suppose "maintained alongside" is supposed to be a version of "maintained in the same repo as", with a little extra wiggle room in case it ends up in a separate repo.

Copy link
Contributor

@ljharb ljharb Feb 25, 2025

Choose a reason for hiding this comment

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

Each TC39 proposal has one or more champions. It is very rare for a champion to maintain a polyfill for that proposal, unless the champion happens to be me.

For web APIs, I'm not aware of the status, but I don't think there's that many web API polyfill authors out there.

Copy link
Member

Choose a reason for hiding this comment

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

Alright that sounds reasonable. Linking to that example would still help.

Copy link
Contributor

@ljharb ljharb left a comment

Choose a reason for hiding this comment

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

This looks great to me, thanks!

@Josh-Cena
Copy link
Member

There are some other policies I'd like to get clarification on, but I don't think we have agreement. For example, do polyfill links expire? Do we remove them after X years of baseline (my personal vote is that once we have a polyfill link it stays forever)? Is polyfill link inclusion by discretion of the writer, or are they part of the page template and omission is considered a bug? Are we required to have links for each and every API with available polyfills? And so on. Probably you intend for those to be clarified in follow-ups.

@github-actions github-actions bot added size/m [PR only] 51-500 LoC changed and removed size/s [PR only] 6-50 LoC changed labels Feb 25, 2025
@wbamberg
Copy link
Collaborator Author

Probably you intend for those to be clarified in follow-ups.

🤣 probably yes. I don't have strong opinions on those issues personally. I suppose I think that "rules for rules sake" are not really worth it - for example, requiring that people include polyfills for APIs if they exist. For the Trusted Types API, for instance, I believe we want to talk about the polyfill, because we want general security guidance to talk about trusted types, and it doesn't yet have cross-browser support. Once TT has been shipping cross-browser for a few years, I'd be happy to take it out too. So it's really just a pragmatic thing.

We could just make this page about JS, where the story is more precise, but it seems more helpful to talk about Web APIs as well, even just in the sense of "describing our current slightly vague practice" rather than making up rules we must follow. And yes, we can always refine it later on.

@Josh-Cena
Copy link
Member

I'm happy with this version.

```md
- [Polyfill for `featureName` in `project-name`](link)
```

Copy link
Collaborator

Choose a reason for hiding this comment

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

When should it be removed? My understanding is that we remove the links when there is support in all browsers in the head revision. Needs to be confirmed.

Copy link
Member

Choose a reason for hiding this comment

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

See above ^ My personal vote is to keep them forever, since any responsible software needs to support browsers that are at least a few years old.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I have no firm opinion. If ^^^ is agreed, then it is worth spelling out the policy though.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

As #38326 (comment) says, I'd prefer to defer these conversations. This PR is just to move things along a bit, so we can even have a documented polyfill policy, and allow other polyfills than core-js. That alone has taken several years to get done!

Comment on lines 23 to 28
Sources are selected by the MDN maintainers based on the following criteria:

- Conformance to the specification for the feature for which they are providing an implementation.
- Adoption by the web development community, as seen in metrics such as the number of [npm](https://www.npmjs.com/) downloads.

Anyone can propose that MDN should recognize an additional source of polyfills by [starting a discussion in the MDN discussion forum](https://github.com/orgs/mdn/discussions). However, the MDN maintainers expect the number of recognized polyfills linked from MDN to remain very small, to reduce the risk of recommending polyfills that cause problems for web developers.
Copy link
Collaborator

@hamishwillee hamishwillee Feb 27, 2025

Choose a reason for hiding this comment

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

I would give this its own heading. Depending on how the discussion falls out in https://github.com/mdn/content/pull/38326/files#r1970347778 I would move the whole heading up a level, shared by both web APIs and JavaScript.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I split the policy at this level because I think currently our JS policy is much more advanced than our Web/API policy. In fact you can't really call our usage in Web/API a policy at all, I just tried to document our practice as I see it. I don't know if we want to allow "non-spec WG" polyfills for Web/API at all, we haven't even had that conversation, And, again, the idea of this PR is to unblock the situation wrt JavaScript polyfills.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I will add the extra heading though 👍

…ndex.md

Co-authored-by: Hamish Willee <hamishwillee@gmail.com>
@@ -5,7 +5,7 @@ page-type: mdn-writing-guide
sidebar: mdnsidebar
---

This page outlines MDN's policy for including polyfills in two areas of the reference documentation: the [JavaScript documentation](/en-US/docs/Web/JavaScript), and the [documentation of Web APIs](/en-US/docs/Web/API).
This page outlines MDN's policy for including polyfills in the reference documentation for [JavaScript](/en-US/docs/Web/JavaScript), and [Web APIs](/en-US/docs/Web/API).
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think I left a comma in there that I shouldn't have.

wbamberg and others added 3 commits March 3, 2025 15:45
…ndex.md

Co-authored-by: Hamish Willee <hamishwillee@gmail.com>
* origin/polyfills:
  Update files/en-us/mdn/writing_guidelines/page_structures/polyfills/index.md
@wbamberg wbamberg requested a review from hamishwillee March 4, 2025 00:04
Copy link
Collaborator

@hamishwillee hamishwillee left a comment

Choose a reason for hiding this comment

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

LGTM given the constraints. Approved but not merged so you can decide if you've had enough feedback.

@wbamberg
Copy link
Collaborator Author

wbamberg commented Mar 4, 2025

Thanks for the review Hamish. This has had enough review and previous discussion that I'm happy to merge :).

@wbamberg wbamberg merged commit 15be229 into mdn:main Mar 4, 2025
8 checks passed
@ljharb
Copy link
Contributor

ljharb commented Mar 4, 2025

Awesome! Does that now mean I can prepare a PR to add all the es-shims polyfills?

@Josh-Cena
Copy link
Member

Yes, please do so :P Wherever we have core-js an equivalent es-shims link should be added too.

estelle pushed a commit that referenced this pull request Mar 5, 2025
* Add a page on polyfills

* ...

* Review

* Update files/en-us/mdn/writing_guidelines/page_structures/polyfills/index.md

Co-authored-by: Hamish Willee <hamishwillee@gmail.com>

* Update files/en-us/mdn/writing_guidelines/page_structures/polyfills/index.md

Co-authored-by: Hamish Willee <hamishwillee@gmail.com>

* Review feedback

---------

Co-authored-by: Hamish Willee <hamishwillee@gmail.com>
@ljharb ljharb mentioned this pull request Mar 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Content:Meta Content in the meta docs size/m [PR only] 51-500 LoC changed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants