project icon indicating copy to clipboard operation
project copied to clipboard

Project: Modernizing JS in MDN examples and code snippets

Open teoli2003 opened this issue 3 years ago • 1 comments

MDN uses old-fashioned JavaScript in numerous places: code snippets, code examples, and larger samples (in dom-examples). This state is mainly a consequence of the development process. We create a page using the convention of the time, and then the page is not updated until the subsequent rewriting of the area, which can be several years later.

Not using modern JS is not an optimal solution because:

  • MDN examples look old-fashioned, giving the wrong feeling that MDN is not up-to-date.
  • New JS syntaxes, in many cases, are more complex to read. For example, a lot of for(;;) are more complex than the equivalent for...of or .forEach()equivalent.
  • Some syntaxes are now considered bad practice, like using the var keyword, which makes code difficult to maintain.

On the other side, sticking to basic syntax is good:

  • For people stuck with old engines.
  • People that don't know some of the recent syntaxes.

Nevertheless, I believe this is harmful to the development of the web, and I would like to see our code updated.

How will we proceed?

  • [x] Launch a discussion to reach a consensus about the changes
  • [ ] Update MDN Code guidelines to reflect the consensus
  • [ ] Lead the community so that these changes are done little by little, either horizontally, meaning in every article of MDN, or vertically, meaning all changes simultaneously in a given API. We will break down this activity into smaller actions according to the outcome of the discussion.

The last activity will likely spread over several Quarters.

teoli2003 avatar Jul 14 '22 06:07 teoli2003

The discussion has been launched: https://github.com/mdn/mdn-community/discussions/143

teoli2003 avatar Jul 14 '22 07:07 teoli2003

The last activity will likely spread over several Quarters.

Are we at this point now? Can you update this issue with the current state and maybe close it if there are no specific next actions for us? (or open new projects)

Elchi3 avatar Sep 05 '22 10:09 Elchi3

Yes, we have fixed in mdn/content. Fixing mdn/*-examples will be another project as we want to get rid of some old Web APIs at the same time.

teoli2003 avatar Sep 05 '22 10:09 teoli2003