-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Description
On wasm32, url adds 279KB to the compiled binary size. A significant chunk of that is because of IDN support, which requires a large look-up table.
wasm32 targets have web_sys::Url, which provides similar functionality to url::Url at much a smaller binary size. It even supports IDN on modern browsers, which have their own internal look-up table.
reqwest should be able to use web_sys::Url instead of url::Url on wasm32 targets, or some other generic url::Url-like trait.
Detail / background
There have been attempts in the url crate to make idna support optional to cut down most of this size, however they have been rolled back, and progress appears stalled.
The current upstream-recommended work-around is to patch out the idna crate with a replacement which implements the same API. There aren't any browser/JS APIs which provide IDN support in a way that could replace the idna crate. One could break IDNA support entirely – but that's not great.
However, wasm32 targets do expose the web_sys::Url type, which supports IDN just fine on modern browsers.
The request here is for reqwest to be able to use web_sys::Url instead of url::Url on wasm32 targets.
That look-up table overhead exists on all other platforms as well, and it may be better to have reqwest define a trait that allows easily swapping out the Url implementation.