All Projects → ElemeFE → Obsolete Webpack Plugin

ElemeFE / Obsolete Webpack Plugin

Licence: mit
🌈 A Webpack plugin generates a browser-side standalone script that detects browser compatibility based on `Browserslist` and prompts website users to upgrade it.

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Obsolete Webpack Plugin

Uglifyjs Webpack Plugin
[deprecated] UglifyJS Plugin
Stars: ✭ 1,343 (+807.43%)
Mutual labels:  webpack, webpack-plugin
Webworkify Webpack
launch a web worker at runtime that can require() in the browser with webpack
Stars: ✭ 105 (-29.05%)
Mutual labels:  webpack, browser
Gas Webpack Plugin
Webpack plugin for Google Apps Script
Stars: ✭ 97 (-34.46%)
Mutual labels:  webpack, webpack-plugin
Webpack Core Usage
webpack2完整系列课程,欢迎阅读。同时欢迎移步我的react全家桶文章全集: https://github.com/liangklfangl/react-article-bucket
Stars: ✭ 94 (-36.49%)
Mutual labels:  webpack, webpack-plugin
Webpack Visualizer
Visualize your Webpack bundle
Stars: ✭ 1,664 (+1024.32%)
Mutual labels:  webpack, webpack-plugin
Fork Ts Checker Webpack Plugin
Webpack plugin that runs typescript type checker on a separate process.
Stars: ✭ 1,343 (+807.43%)
Mutual labels:  webpack, webpack-plugin
Worker Plugin
👩‍🏭 Adds native Web Worker bundling support to Webpack.
Stars: ✭ 1,840 (+1143.24%)
Mutual labels:  webpack, webpack-plugin
Add Asset Webpack Plugin
Dynamically add an asset to the Webpack graph
Stars: ✭ 84 (-43.24%)
Mutual labels:  webpack, webpack-plugin
Rollbar Sourcemap Webpack Plugin
A Webpack plugin to upload sourcemaps to Rollbar
Stars: ✭ 127 (-14.19%)
Mutual labels:  webpack, webpack-plugin
Terser Webpack Plugin
Terser Plugin
Stars: ✭ 1,687 (+1039.86%)
Mutual labels:  webpack, webpack-plugin
Jest Webpack
Use jest with webpack.
Stars: ✭ 89 (-39.86%)
Mutual labels:  webpack, webpack-plugin
Svg Sprite Loader
Webpack loader for creating SVG sprites.
Stars: ✭ 1,822 (+1131.08%)
Mutual labels:  webpack, webpack-plugin
Ngc Webpack
Angular compiler-cli with webpack's loader chain.
Stars: ✭ 87 (-41.22%)
Mutual labels:  webpack, webpack-plugin
Bundle Stats
In-depth bundle analyzer for webpack(bundle size, assets, modules, packages)
Stars: ✭ 144 (-2.7%)
Mutual labels:  webpack, webpack-plugin
Auxpack
A dashboard for monitoring Webpack build stats.
Stars: ✭ 86 (-41.89%)
Mutual labels:  webpack, webpack-plugin
Webpack Tools
☕️Just a simple webpack sample project.
Stars: ✭ 106 (-28.38%)
Mutual labels:  webpack, webpack-plugin
Page Builder
自定义页面构建平台
Stars: ✭ 81 (-45.27%)
Mutual labels:  webpack, webpack-plugin
Google Fonts Plugin
Webpack plugin that downloads fonts from Google Fonts and encodes them to base64
Stars: ✭ 83 (-43.92%)
Mutual labels:  webpack, webpack-plugin
Everything Is A Plugin
Everything is a Plugin: Mastering webpack from the inside out. NgConf 2017
Stars: ✭ 123 (-16.89%)
Mutual labels:  webpack, webpack-plugin
Size Plugin
Track compressed Webpack asset sizes over time.
Stars: ✭ 1,665 (+1025%)
Mutual labels:  webpack, webpack-plugin

Obsolete Webpack Plugin

npm npm npm npm node npm licenses

Introduction 🌟

A Webpack plugin generates a browser-side standalone script that detects browser compatibility based on Browserslist and prompts website users to upgrade it.

Motivation 💥

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, Exponentiation Operator, we can transform all of them through AST parser. For next built-in features, such as Promise, WeakMap, String.prototype.padstart, we can provide pollyfills that mimic native functionality. However, for some browser only features, such as Service Worker, WebAssembly, CSS Grid Layout, 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 ⚡️

Prerequisite

  • Node >=8.3.0
  • Webpack 4.x

Installation

$ npm i -D obsolete-webpack-plugin

Basic Usage

Apply the plugin in your Webpack configuration, often used together with html-webpack-plugin. By the way, the putting order of plugins is irrelevant.

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, we are able to fulfill this goal easily.

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 📖

Options

Name Type Default Description
name string 'obsolete' The chunk name.
template string '<div>Your browser is not supported. <button id="obsoleteClose">&times;</button></div>' The prompt html template. It accepts any document fragment. E.g., '<style>...</style><div>...</div><script>...</script>'. Specially, the template will be removed when a node with attribute id="obsoleteClose" is clicked.
position string 'afterbegin' If set 'afterbegin', the template will be injected into the start of body.
If set 'beforeend', the template will be injected into the end of body.
browsers string[] Browsers to support, overriding global browserslist configuration.
promptOnNonTargetBrowser boolean false If the current browser useragent doesn't match one of the target browsers, it's considered as unsupported. Thus, the prompt will be shown. E.g., your browserslist configuration is ie > 8, by default, the prompt won't be shown on Chrome or Safari browser. E.g., your browserslist configuration is ie > 8, by default, the prompt won't be shown on Chrome or other browsers. Another e.g., your browserslist configuration is chrome > 80, by default, the prompt won't be shown on IE or other browsers.
promptOnUnknownBrowser boolean true If the current browser useragent is unknown, the prompt will be shown.

Demonstration 🎨

Browser Support 👓

The name matches Browserslist queries.

Desktop

IE Edge Chrome Safari Firefox Opera Electron

Mobile

ChromeAndroid Android
(5+, WebView)
iOS
(OS)

FAQ 🍵

Q: Does this plugin support Yandex, Maxthon, UC or QQ browser?

A: Yep. This plugin supports those browsers based on the mainstream browser kernel, such as Chromium based browser, Mozilla based browser. In other words, Chrome >= 30 will be also applied to Yandex browser, ChromeAndroid >= 30 will be also applied to Android UC browser.

Q: Does plugin work in IE 6?

A: Yep. This plugin supports browsers that implement the full ES3 spec. Although the source code is ES2015+, it will be compiled and shimmed to the target environment eventually.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].