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

Writing forward-compatible websites is outdated #19717

Open
estelle opened this issue Aug 19, 2022 · 3 comments
Open

Writing forward-compatible websites is outdated #19717

estelle opened this issue Aug 19, 2022 · 3 comments
Labels
Content:Guide Guide docs

Comments

@estelle
Copy link
Member

estelle commented Aug 19, 2022

MDN URL

https://developer.mozilla.org/en-US/docs/Web/Guide/Writing_forward-compatible_websites

What specific section or headline is this issue about?

javascript

What information was incorrect, unhelpful, or incomplete?

I think we've switched to recommend not using window. and this article recommends using window.
This page needs some modern love.

What did you expect to see?

Modern best practices

Do you have any supporting links, references, or citations?

No response

Do you have anything more you want to share?

No response

MDN metadata

Page report details
@github-actions github-actions bot added the needs triage Triage needed by staff and/or partners. Automatically applied when an issue is opened. label Aug 19, 2022
@teoli2003
Copy link
Member

I think we've switched to recommend not using window. and this article recommends using window. This page needs some modern love.

It is a bit more complex than this. If you speak about something related to the window, you still prefix it. I would say window.onload for example, meaning code to execute once the window and its content has loaded (that is, the UI).

But if you speak about something on the global scope, like setInterval(), you don't prefix it or, if you copy and paste the line (for whatever reason), into a worker or a service worker, it won't work anymore (as there is no window). By not prefixing it, or prefixing it with self. it will work in both places.

@rubiesonthesky
Copy link
Contributor

I was looking this another day and was confused about this section, https://developer.mozilla.org/en-US/docs/Web/Guide/Writing_forward-compatible_websites#avoid_missing . Is leaving out ">" a convention that people were doing? You can write all sorts of incorrect syntax that will seem to work in browser. But highlighting just one example feels weird. Writing correct syntax should not be just future proofing but good practice always anyway. I think it would make more sense to me, if the emphasis would be that "write correct syntax AND use some validation tool to find trivial mistakes". And then links / mentions where you could find more info about that.

@Josh-Cena
Copy link
Member

Josh-Cena commented Aug 19, 2022

The point about "qualify your globals" is still fair. We could recommend globalThis if it helps with portability, but I think it's just talking about web here anyway?

@sideshowbarker sideshowbarker added Content:Guide Guide docs and removed needs triage Triage needed by staff and/or partners. Automatically applied when an issue is opened. labels Aug 22, 2022
estelle added a commit that referenced this issue Apr 21, 2023
teoli2003 pushed a commit that referenced this issue Apr 22, 2023
* removed vendor prefix advice

* address issue

#19717 (comment)

* remove space
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Content:Guide Guide docs
Projects
None yet
Development

No branches or pull requests

5 participants