youtube / spfjs

A lightweight JS framework for fast navigation and page updates from YouTube
https://youtube.github.io/spfjs/
MIT License
2.24k stars 147 forks source link

Use XHR2 `responseType = "json"` when possible #317

Closed nicksay closed 9 years ago

nicksay commented 9 years ago

Chrome and Firefox support setting responseType = "json" on XMLHttpRequest objects: https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest#Properties

This allows the browser to parse JSON on a separate thread before returning. Since every request always does a full parse for error-handling (https://github.com/youtube/spfjs/blob/b3c4f07e99f9c5d62f9f3ec59f86c52302edd549/src/client/nav/request.js#L350) using the value provided by responseType = "json" may reduce main thread contention slightly.

This is primarily a concern when loading very large responses.

nicksay commented 9 years ago

Investigated this a little more:

Positive

Negative