-
Notifications
You must be signed in to change notification settings - Fork 328
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove polyfills for IE #2506
Comments
On a project I removed the polyfills in the build step, sharing here if anyone is Googling finds this issue and wants to do the same:
Rollup Plugin: // file: rollup-remove-polyfills.js
// Based on https://github.com/proteriax/rollup-plugin-ignore
// Replace polyfills with empty files that'll get removed with tree shaking.
function removePolyfills() {
const emptyFile = "export default {}";
const emptyFileName = "\0rollup_plugin_ignore_empty_module_placeholder";
return {
resolveId(importee) {
return importee.includes("vendor/polyfills") ? emptyFileName : null;
},
load(id) {
return id === emptyFileName ? emptyFile : null;
},
};
}
module.exports = removePolyfills; // file: index.mjs
import { initAll } from "govuk-frontend/govuk-esm/all.mjs";
initAll(); rollup ./index.mjs --file output.js --plugin ./rollup-remove-polyfills.js |
Is there something else to review after #3570 or should this go back to in progress / backlog? |
Paging @claireashworth, since the last bit of work on this is documentation. Though we first have to decide what polyfilling actually looks like going forward. |
This is done! |
What
At the moment, we ship polyfills to all browsers even when they're not needed. We think around 50% of the JavaScript we ship is polyfills (this might say more about the amount of JavaScript we have, rather than the size of the polyfills).
Having to include polyfills also means we tend to restrict ourselves to features that we know are either 1) well supported, or 2) don't require large polyfills to work in older browsers.
Why
There is a performance impact if we're shipping unnecessary JavaScript to browsers that don't need it.
Our current approach puts some restrictions on the JavaScript features we use. This isn't necessarily causing problems right now, but might do in future when we come to build more complex components. (also depends on #2503 )
Who needs to work on this
Developers
Who needs to review this
Developers
Done when
Depends on our browser support proposal being approved by the community. If we go down the route of dropping IE support to 'functional':
The text was updated successfully, but these errors were encountered: