v4 replaces the whatwg-url-without-unicode dependency with a purpose-built, dependency-free implementation of the WHATWG URL Standard.
The result is a polyfill that is substantially smaller and faster on Hermes, with stronger standards compliance and test coverage.
65% Smaller
Measured in a production Metro bundle with React Native 0.86.0:
| Version | Bundle impact |
|---|---|
| v3.0.0 | 73.02 kB |
| v4.0.0 | 25.50 kB |
That is 47.52 kB less, a 65.1% reduction in added bundle size.
Faster Than v3 on Hermes
Using the standalone Hermes runtime from React Native 0.81.4, v4 was faster than v3's whatwg-url-without-unicode implementation in every comparable workload.
| Operation | Improvement |
|---|---|
| Absolute URL construction | 3.60x faster |
| Relative URL construction | 3.28x faster |
| Percent-encoded URL construction | 3.72x faster |
| URL property getters | 2.71x faster |
| URL setters | 3.34x faster |
URLSearchParams parsing |
7.82x faster |
URLSearchParams stringification |
2.43x faster |
URLSearchParams manipulation |
5.52x faster |
Repeated URLSearchParams mutation |
1.43x faster |
| URL/search params roundtrip | 4.46x faster |
Repeated attached searchParams.append() |
~259x faster |
Most comparable workloads improved by 2.4x to 7.8x.
Faster Than Expo on Hermes
v4 was also faster than Expo's whatwg-url-minimum@0.1.2 implementation in 13 of 14 workloads.
| Operation | Improvement |
|---|---|
| Absolute URL construction | 2.31x faster |
| Relative URL construction | 2.14x faster |
URL.canParse() with valid input |
2.20x faster |
URL.parse() |
2.25x faster |
| Percent-encoded URL construction | 1.81x faster |
| URL setters | 1.98x faster |
URLSearchParams parsing |
2.08x faster |
| URL/search params roundtrip | 1.69x faster |
Repeated attached searchParams.append() |
~59x faster |
Expo was 1.49x faster in the isolated repeated URLSearchParams.set()/delete() workload. URL property getters were effectively tied, with v4 measuring 1.04x faster.
These benchmarks use the desktop standalone Hermes runtime bundled with React Native 0.81.4. They are useful for comparing implementations under the same runtime, but are not representative of device performance.
More Trustworthy
v4 considerably expands standards and runtime coverage:
- Added a pinned official Web Platform Tests suite for
URLandURLSearchParams. - Added WebIDL conformance coverage.
- Added WPT execution inside React Native on Hermes.
- Added React Native 0.84 Android coverage.
- Verified that public types remain compatible with Node.js and
whatwg-url. - Added dedicated Node and standalone-Hermes benchmark runners.
The release passes 1,703 tests, including all 28 pinned WPT files and variants. The only documented exceptions require IDNA processing, which remains intentionally excluded to keep the polyfill lightweight.
New API
Added URL.parse(), which returns a parsed URL or null when the input is invalid.
URL.parse('https://example.com');
// URL
URL.parse('not a URL');
// nullUpgrading
The documented URL, URLSearchParams, setupURLPolyfill(), and react-native-url-polyfill/auto APIs remain available.
Applications relying on undocumented quirks of the previous whatwg-url-based implementation should verify their URL handling after upgrading.
As before, Unicode/IDNA hostname processing is intentionally unsupported.
What's Changed
- Implement our own spec-compliant polyfill in #497
- Add official WPT and Hermes coverage in #501
- Optimize ASCII parser classification in #499
- Optimize repeated
URLSearchParamsmutations in #502 - Optimize attached
URLSearchParamsappends in #503 - Optimize UTF-8 percent encoding in #504
- Optimize
URL.canParse()and normalized parsing in #505 - Optimize
URLSearchParamsmutations and benchmarks in #506 - Harden URL WebIDL conformance in #507
- Fix pre-release package contents and types in #508
- Add standalone Hermes benchmark runner in #509
Full Changelog: v3.0.0...v4.0.0