Right now, the Response object lazily parses the response body, based on what "getter" method is called: json(), text(), etc. The json method will attempt to parse the body at the time the method is called, which can be expensive for large requests. By allowing the response type to be declared ahead of time, XMLHttpRequest can perform the parsing on a separate thread before firing the load event.
Supporting this would be easy, but some thought should be given to how this should affect the existing fetch-response-like "getters" design, and how that design may encourage less-performant behavior.
CC: @IgorMinar
Right now, the
Responseobject lazily parses the response body, based on what "getter" method is called:json(),text(), etc. Thejsonmethod will attempt to parse the body at the time the method is called, which can be expensive for large requests. By allowing the response type to be declared ahead of time,XMLHttpRequestcan perform the parsing on a separate thread before firing theloadevent.Supporting this would be easy, but some thought should be given to how this should affect the existing fetch-response-like "getters" design, and how that design may encourage less-performant behavior.
CC: @IgorMinar