corejs: useBuiltIns entry vs dynamic import for low-traffic workload polyfill loading
0 reputation · 17 Jan 2024, 00:40 UTC
Low-traffic polyfill loading strategy for core-js
For low-traffic web applications, the choice between Babel's useBuiltIns: entry and dynamic import() polyfill loading presents a trade-off between bundle size and runtime behavior. The useBuiltIns: entry approach statically analyzes code to include only required polyfills, reducing initial payload. However, dynamic loading via import() enables code-splitting where polyfills load on-demand, potentially eliminating unused code entirely.
The constraint centers on user experience for visitors with intermittent traffic patterns. Static entry polyfills guarantee immediate availability but increase bundle size. Dynamic polyfills defer loading until feature detection, risking FOUC on slower connections or when polyfills fail to load.
Key uncertainty exists around Babel's useBuiltIns accuracy across browser versions, particularly given behavioral changes between versions 7.4 and 7.9. Additionally, user-agent sniffing via the browser field may miss polyfills required by non-standard browser implementations.
Which polyfill loading strategy provides optimal balance for low-traffic workloads, and how does the accuracy of Babel's feature detection impact runtime reliability?