amphtml icon indicating copy to clipboard operation
amphtml copied to clipboard

`isDocumentReady` predicate always returns true

Open rcebulko opened this issue 3 years ago • 2 comments

In #core/document/ready, we check if document.readyState is either loading or uninitialized. According to https://developer.mozilla.org/en-US/docs/Web/API/Document/readyState, only the first is possible (TypeScript surfaced this error). uninitialized isn't even one of the custom ready states (defined in #core/constants/ready-state) used in custom-element. As far as I can tell, Document#readyState is a readonly property, so unless we're doing something really weird, we should drop the second half of this conditional, which I'm guessing is old dead code.

https://github.com/ampproject/amphtml/blob/main/src/core/document/ready.js#L7

/cc @jridgewell to tell me if I'm missing something.

rcebulko avatar Oct 11 '21 17:10 rcebulko

To respond to the title, the Browser can change the value. We expect the value to be loading until the full HTML has downloaded, then it'll change to interactive or complete when the resources finish. You'll only really notice loading with really long HTML documents that reference an inline script, and interactive on docs that have slow-loading images.

uninitialized isn't even one of the custom ready states (defined in #core/constants/ready-state) used in custom-element.

uninitialized is an old, non-standard IE6 value. I'm not sure which version of IE phased it out, but we should be able to remove now.

jridgewell avatar Oct 11 '21 21:10 jridgewell

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Oct 16 '22 07:10 stale[bot]