# obsolete-webpack-plugin **Repository Path**: mirrors_ElemeFE/obsolete-webpack-plugin ## Basic Information - **Project Name**: obsolete-webpack-plugin - **Description**: 🌈 A Webpack plugin generates a browser-side standalone script that detects browser compatibility based on `Browserslist` and prompts website users to upgrade it. - **Primary Language**: Unknown - **License**: MIT - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2020-08-08 - **Last Updated**: 2026-03-21 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # Obsolete Webpack Plugin [](https://circleci.com/gh/ElemeFE/obsolete-webpack-plugin) [](https://ci.appveyor.com/project/chikara-chan/obsolete-webpack-plugin) [](https://codecov.io/github/ElemeFE/obsolete-webpack-plugin) [](https://npmjs.com/package/obsolete-webpack-plugin) [](https://nodejs.org) [](https://unpkg.com/obsolete-web/dist/obsolete.min.js) [](https://gitlab.alibaba-inc.com/eleme-fe-lpd/obsolete-webpack-plugin/blob/master/LICENSE) ## Introduction :star2: A Webpack plugin generates a browser-side standalone script that detects browser compatibility based on [Browserslist](https://github.com/browserslist/browserslist) and prompts website users to upgrade it. ## Motivation :collision: In modern front-end development, we use toolchain to convert next JavaScript version into a backwards compatible version of JavaScript that works in older browser environment. For next syntax features, such as [Object Rest/Spread Properties](https://tc39.github.io/proposal-object-rest-spread/), [Exponentiation Operator](http://rwaldron.github.io/exponentiation-operator/), we can transform all of them through [AST](https://astexplorer.net/) parser. For next built-in features, such as [Promise](https://tc39.github.io/ecma262/#sec-promise-objects), [WeakMap](https://tc39.github.io/ecma262/#sec-weakmap-objects), [String.prototype.padstart](https://tc39.github.io/ecma262/#sec-string.prototype.padstart), we can provide pollyfills that mimic native functionality. However, for some browser only features, such as [Service Worker](https://w3c.github.io/ServiceWorker/), [WebAssembly](https://webassembly.github.io/spec/js-api/), [CSS Grid Layout](https://drafts.csswg.org/css-grid/), no polyfills support these or partially support. In the worst case, our users who use old browsers open a website but catch a sight of blank page. It may be a bad network condition, may be syntax parsing error, may be built-in losing. But they must not realize that the browser they using does not meet the requirements of our website target. Therefore, we need a mechanism to notify that they should upgrade their browser before accessing content. Thus, this plugin borns. ## Getting Started :zap: ### Prerequisite - Node >=8.3.0 - Webpack 4.x ### Installation ```sh $ npm i -D obsolete-webpack-plugin ``` ### Basic Usage Apply the plugin in your Webpack configuration, often used together with [html-webpack-plugin](https://github.com/jantimon/html-webpack-plugin). By the way, the putting order of plugins is irrelevant. ```js const HtmlWebpackPlugin = require('html-webpack-plugin'); const ObsoleteWebpackPlugin = require('obsolete-webpack-plugin'); module.exports = { // ... plugins: [ // ... new HtmlWebpackPlugin(), new ObsoleteWebpackPlugin() ] }; ``` ### Best Practice To improve first page load speed, you should always reduce render-blocking scripts as far as possible. For non-critical script, it's best to mark them with the `async` attribute. Thanks to [script-ext-html-webpack-plugin](https://github.com/numical/script-ext-html-webpack-plugin), we are able to fulfill this goal easily. ```js const HtmlWebpackPlugin = require('html-webpack-plugin'); const ObsoleteWebpackPlugin = require('obsolete-webpack-plugin'); const ScriptExtHtmlWebpackPlugin = require('script-ext-html-webpack-plugin'); module.exports = { // ... plugins: [ new HtmlWebpackPlugin(), new ObsoleteWebpackPlugin({ name: 'obsolete' }), new ScriptExtHtmlWebpackPlugin({ async: 'obsolete' }) ] }; ``` ## Configuration :book: ### Options | Name | Type | Default | Description | :-: | :-: | :-: | :-: | name | string | `'obsolete'` | The chunk name. | template | string | `'