emscripten-core / emscripten-core/emscripten

Use Fetch in preference of XMLHttpRequest (on supported platforms)

Open
#6,241 17 comments 4 reactions 0 assignees View on GitHub
good first bug help wanted
Dominant language
C++
Stars
27.6k
Forks
3.6k
Avg merge
1d 1h
Merged PRs (30d)
105

Description

## Background
I wrote up some background on the emscripten-discuss group [here](https://groups.google.com/forum/#!topic/emscripten-discuss/TcXrYOOcG5s).

To summarise, src/shell.js contains some calls to XMLHttpRequest (XHR). The [Fetch API](https://fetch.spec.whatwg.org/) is a replacement for XHR, that has quite widespread support (https://caniuse.com/#search=fetch). [Service Worker](https://www.w3.org/TR/service-workers-1/) does not support XHR in Chrome or Firefox (I have not tested other browsers).

## Affected files
src/shell.js

## Proposed solution
Use Fetch in preference to XHR on supported platforms.

## Known/potential problems
Fetch does not support the File URI scheme ([ticket](https://github.com/github/fetch/pull/92#issuecomment-140665932)). Further analysis is required to understand how this would affect emscripten. XHR might be required as a fallback.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.