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

Using "Performance.now" is confusing #30238

Open
davepullin opened this issue Nov 13, 2023 · 8 comments
Open

Using "Performance.now" is confusing #30238

davepullin opened this issue Nov 13, 2023 · 8 comments
Labels
Content:WebAPI Web API docs needs decision The task needs consensus through discussion

Comments

@davepullin
Copy link

MDN URL

https://developer.mozilla.org/en-US/docs/Web/API/Performance_API/High_precision_timing

What specific section or headline is this issue about?

throughout the page

What information was incorrect, unhelpful, or incomplete?

Is it Performance or performance? You keep switching the capitalization!

What did you expect to see?

The same (and correct) capitalization is each place.

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
@davepullin davepullin added the needs triage Triage needed by staff and/or partners. Automatically applied when an issue is opened. label Nov 13, 2023
@github-actions github-actions bot added the Content:WebAPI Web API docs label Nov 13, 2023
@bsmth bsmth removed the needs triage Triage needed by staff and/or partners. Automatically applied when an issue is opened. label Nov 13, 2023
@bsmth
Copy link
Member

bsmth commented Nov 13, 2023

Thanks for reporting @davepullin - the reason for capitalization is that the page is referring to a Web API - 'the Performance API' and when referencing the topic of performance, it follows normal sentence casing - 'For measuring performance...'.

All of the APIs follow this convention: https://developer.mozilla.org/en-US/docs/Web/API, for instance:

The File System API allows read, write and file management capabilities to access files on the device file system.

Does that make sense?

@davepullin
Copy link
Author

davepullin commented Nov 13, 2023 via email

@Josh-Cena
Copy link
Member

Performance is indeed a class (an "interface", in IDL terms), but you don't use its constructor; instead, you use the exposed singleton instance called performance. When we say Performance.now(), we really mean the now() method of Performance instances, which you access via performance.now() in actual code. Web API docs don't differentiate between static and instance properties, but sometimes we write them in lowercase for pragmatic reasons. I'm okay to change the uppercase to lowercase on this page wherever applicable.

@davepullin
Copy link
Author

davepullin commented Nov 13, 2023 via email

@wbamberg
Copy link
Collaborator

It's hard to know what to do here. Our pretty consistent practice is to describe Web API methods in prose like InterfaceName.methodName(). This is confusing because for non-static methods you can't actually call it like that. And it is even more confusing in cases, like this one, where there is actually a global named interfaceName.

But that's our practice, and doing something different for just this one page feels wrong. And there's a good reason it is our practice, because writing something like "The methodName() method of the InterfaceName interface" gets really clunky.

@OnkarRuikar
Copy link
Contributor

This is confusing because for non-static methods you can't actually call it like that. And it is even more confusing in cases, like this one, where there is actually a global named interfaceName.

I agree. Can we have . and # used as follows:

Number.EPSILON;  // static. When referenced using an interface
Number#toString();  // non-static. When referenced using an interface
myNumer.toString(); // non-static. Referenced using an instance

Performance.call();  //static
Performance#now(); // non-static
performance.now();  // non-static

The heading here could be Performance#now() vs Date.now().

For example

  • Java documentation uses '#' to document class members.
  • Ruby uses "::" for class methods, and "#" for instance methods.

@wbamberg
Copy link
Collaborator

wbamberg commented Feb 15, 2024

This is a variant of https://discourse.mozilla.org/t/incorrect-titles-for-method-property-articles/31641 and https://github.com/orgs/mdn/discussions/248, which we fixed for titles, but not for in-prose references.

InterfaceName#methodName() has been proposed before, and has its detractors.

FWIW web.dev seems pretty settled on interfaceName.methodName().

@OnkarRuikar
Copy link
Contributor

InterfaceName#methodName() has been proposed before, and has its detractors.

Ohh. Using other characters instead won't be welcomed either because they might have some meaning in JS.

FWIW web.dev seems pretty settled on interfaceName.methodName().

We could also ban InterfaceName.instanceMethod() and start using interfaceName.instanceMethod() everywhere. No need to change InterfaceName.staticMethod().

@Josh-Cena Josh-Cena added the needs decision The task needs consensus through discussion label Jun 20, 2024
@Josh-Cena Josh-Cena changed the title Is it Performance or performance? You keep switching the capitalization! Using "Performance.now" is confusing Jun 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Content:WebAPI Web API docs needs decision The task needs consensus through discussion
Projects
None yet
Development

No branches or pull requests

5 participants