• Stars
    star
    224
  • Rank 177,792 (Top 4 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created almost 10 years ago
  • Updated almost 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Detects outdated browsers and advises users to upgrade to a new version. Handles mobile devices!

Outdated Browser Rework

Detects outdated browsers and advises users to upgrade to a new version. Handles mobile devices!

This is a fork of Burocratik's Outdated Browser, adding a number of new features including:

  • Explicit browser version support
  • Mobile browser support
  • Edge support
  • Substantial size reduction
  • More translations
  • Custom upgrade messages
  • Unminified code
  • Removed adware (Burocratik sold their site to a VPN company)

And more (see below for the full list).

One of the challenges with making this type of module is that the JS and CSS can't use any current tech - the 'get a new browser' message must display on older browsers - so yes, this is hard. We have to use ES3, an ancient version of JavaScript. We can't even use the nice '×' close character (we have to use the letter 'x') since that character doesn't display on some older browsers! This module is tested all the way back to IE6.

This module does not need jQuery.

Demo

There's a demo page here where all browsers are unsupported - this allows you to see the effect! This file is index.html in the source.

Here's a demo you can edit on JSfiddle

Usage (with browserify)

JS

In your template

In <head>, before any other script tags:

<script src="/js/dist/oldbrowser.js"></script>

In oldbrowser.js

Start outdated-browser-rework and call it with your preferred options:

var outdatedBrowserRework = require("outdated-browser-rework");
outdatedBrowserRework();

If you like, specify options, eg:

outdatedBrowserRework({
	browserSupport: {
		Chrome: 57, // Includes Chrome for mobile devices
		Edge: 39,
		Safari: 10,
		"Mobile Safari": 10,
		Firefox: 50,
		Opera: 50,
		Vivaldi: 1,
		// You could specify minor version too for those browsers that need it.
		Yandex: { major: 17, minor: 10 },
		// You could specify a version here if you still support IE in 2017.
		// You could also instead seriously consider what you're doing with your time and budget
		IE: false
	},
	requireChromeOnAndroid: false,
	isUnknownBrowserOK: false,
	messages: {
		en: {
			outOfDate: "Your browser is out of date!",
			unsupported: "Your browser is not supported!",
			update: {
				web: "Update your browser to view this website correctly. ",
				googlePlay: "Please install Chrome from Google Play",
				appStore: "Please update iOS from the Settings App"
			},
			// You can set the URL to null if you do not want a clickable link or provide
			// your own markup in the `update.web` message.
			url: "http://browser-update.org/",
			callToAction: "Update my browser now",
			close: "Close"
		}
	}
});

The particular versions used in this example are the defaults, by the way!

See below for more options.

Browsers that are older than the versions supplied, or who use a browser where support is false, will see a message, depending on their platform:

  • On desktop browsers, users will be directed to browser-update.org/
  • on iOS devices, users will be asked to visit the Settings app and upgrade their OS.
  • On Android devices, users will be directed to Chrome in Google Play.

Usage (without browserify)

In your template

In <head>, before any other script tags:

<script src="/js/dist/outdated-browser-rework.min.js"></script>
<script>
	outdatedBrowserRework();
</script>

See above for the default options.

Options

  • browserSupport: Object - A matrix of browsers and their versions - see above for demo. Anything less will be unsupported. false means all versions are unsupported.
  • requiredCssProperty: String - A CSS property that must be supported.
  • messages: Object - Customize upgrade messages for your purposes. See the above default options for an example.
  • language: String - A language string to be used for the messages in the notification. Default is en. See languages.json for supported languages. Can be used instead of messages if preferred.
  • requireChromeOnAndroid: Boolean - Ask Android users to install Chrome. Default is false.
  • isUnknownBrowserOK: Boolean. Whether unknown browsers are considered to be out of date or not. The default is false, ie. unknown browsers are considered to be out of date. Consider setting true and using requiredCssProperty to catch missing features.

SCSS

If you're using sass-npm you can just import the npm module, and it will load index.scss:

@import "outdated-browser-rework.scss";

Otherwise compile the sass and put it somewhere. Then load that via a link tag inside <head>:

<link rel="stylesheet" href="/css/outdated-browser.css" />

HTML

Add the required HTML at the end of your document:

<div id="outdated"></div>

Yes, IDs suck but old browsers don't support getting elements by class name.

You should also always use HTML <!DOCTYPE> declaration to tell legacy browsers that you're using full standards mode. Without this it's possible that your page gets loaded in the quirks mode and it will not work with this package.
For more information, see: https://developer.mozilla.org/en-US/docs/Web/HTML/Quirks_Mode_and_Standards_Mode

Bundling the JavaScript

In modern times we normally concatenate and combine different JS modules using browserify or webpack: it's best to bundle outdated-browser-rework by itself. Since other scripts may expect things like console and function.bind() to exist, they won't work on old browsers - if you bundle this with other software, the JS will probably fail before outdated-browser has a chance to do any work.

For gulp users

Add the following underneath your existing js task:

gulp
	.src("./public/js/src/oldbrowser.js")
	.pipe(
		browserify({
			debug: !gulp.env.production
		})
	)
	.pipe(gulp.dest("./public/js/dist"));

Doing this will mean that dist/oldbrowser.js will only include outdated-browser-rework and its dependency user-agent-parser, without anything else to get in the way.

For Webpack users

First of all, to bundle outdated-browser-rework by itself, create a new entry point in your webpack config file. You'll also need to install style-loader and css-loader in order to import the package's CSS. Your webpack configuration should look something like this:

const path = require("path");

module.exports = {
	entry: {
		main: path.join(__dirname, "src/index.js"),
		"outdated-browser-rework": path.join(
			__dirname,
			"src/outdated-browser-rework.js"
		)
	},
	module: {
		rules: [
			{
				test: /\.css$/i,
				use: ["style-loader", "css-loader"]
			}
		]
	}
};

Secondly, make use of outdated-browser-rework in src/outdated-browser-rework.js:

import outdatedBrowser from "outdated-browser-rework";
import "outdated-browser-rework/dist/style.css";

outdatedBrowser();

Finally, add the generated JS file in your HTML:

<!DOCTYPE html>
<html>
	<head>
		<title>Webpack example</title>
	</head>
	<body>
		<div id="outdated"></div>
		<script src="outdated-browser-rework.js"></script>
		<script src="main.js"></script>
	</body>
</html>

Outdated Browser Rework Version 2 notes

  • Add isUnknownBrowserOK option to determine how to handle unknown browsers.
  • Add messages to override the default out of date messages.
  • Custom message for unsupported browsers vs out of date versions of browsers
  • Edge versions are now specified directly (rather than using EdgeHTML versions). For example, you now specify Edge 16 rather than 41.
  • Better documentation
  • New translations
  • Custom upgrade messages
  • New false option to disable browser support.
  • IE now defaults to false - ie, display a message telling users to get a new browser on any version of IE. You can still specify 6 to 11 if, for some reason, you still support IE in 2018. Tip: you should not support IE in 2018.
  • CSS file is included
  • Update ua-parser-js to fix parsing some more esoteric UAs

Differences from Bürocratik's Outdated Browser 1.1.0

  • Add explicit browser support via the browserSupport option
  • Add mobile support. Users on iOS and Android will be directed to the Apple App Store and Google Play respectively.
  • Add new requireChromeOnAndroid option
  • Be an NPM module
  • Use SASS (specifically SCSS)
  • No AJAX, languages are only 8K and removing the AJAX library has made the code substantially shorter.
  • Added support for custom upgrade messages

And some code fixes:

  • Pass eslint
  • vanilla JS (no jQuery!)
  • Simplify some variable and function names

There's still some TODOs from the original code:

  • Try and eliminate IDs (they're JS globals, so EUW)
  • Move all styling into SCSS (need to test if this breaks old IEs)
  • Re-do Farsi (RTL) support from original Outdated Browser

Author

This rework is made by Mike MacCana and a whole bunch of amazing open source contributors!

The original Outdated Browser is made with love at Bürocratik

More Repositories

1

python-docx

Reads, queries and modifies Microsoft Word 2007/2008 docx files.
Python
1,068
star
2

powershell-profile

Mike's Powershell Profile (and how to set up Windows console if you've been using *nix for 20 years)
PowerShell
384
star
3

compact-wsl2-disk

A small script for Windows 10 Home users to compact their WSL2 disks
PowerShell
233
star
4

how-to-install-a-linux-development-environment-on-windows

How to install a Linux development environment on Windows using Ubuntu and WSL2
117
star
5

agave

Cleaner, simpler JavaScript for ES6
JavaScript
115
star
6

serverless-starter-kit

A fulllstack serverless app using TypeScript, Svelte and Architect Serverless
TypeScript
67
star
7

stickers

Various stickers I made, printed and gave away at jsconf 2015
63
star
8

whois-json

Whois with results in actual, structured, camelCased JavaScript!
JavaScript
62
star
9

styleselect

Simple, standalone styling for select boxes in modern browsers.
JavaScript
37
star
10

dynamic-template

Simple dynamic ES6 templates
JavaScript
22
star
11

eyes

Removes eyes from the internet
JavaScript
15
star
12

sorts

JavaScript
15
star
13

eslint-plugin-must-use-await

Flags use of callback functions and .then(), for users of ES2017's async/await
JavaScript
11
star
14

kind.js

Return the kind of a JS object (the same as what a human would).
JavaScript
9
star
15

amps-in-the-trunk

Transform HTML directly to Google AMP HTML
JavaScript
8
star
16

companies-house

A JavaScript client for the Companies House API
JavaScript
7
star
17

pyfilter

Python client for pifilter adult image detection service (www.pifilter.com). Useful for helping automate moderation on public forums.
7
star
18

sass-npm

Import SASS files from npm modules
JavaScript
7
star
19

express-geoip

Express 4 middleware to add req.countryCode, which is the ISO alpha 2 country code, to requests.
JavaScript
6
star
20

is-gmail-account-valid

Find out if a gmail address is used or not
JavaScript
5
star
21

boilerplatejs

JavaScript
4
star
22

pr-chart

Simple AWS SAM / TypeScript / Arc / Svelte app
TypeScript
3
star
23

aoftmurmurkeys

Start and pause A Soft Murmur using the F5 key on your keyboard.
JavaScript
3
star
24

japanese_mayonnaise

Minimal Chrome extension. Removes animated notification area from Google search results.
JavaScript
2
star
25

epilepsy

Make your own Enter the Void style credits. With apologies to Tom Kan.
JavaScript
2
star
26

meatspace-enterprise-edition

JavaScript
2
star
27

devils_pie

A tool to solve the 10 Fast Finger Speedtest http://speedtest.10fastfingers.com/
JavaScript
2
star
28

ringespiel.js

A modern carousel for JQuery
JavaScript
2
star
29

express-middleware-to-async

Express to Arc middleware converter (Experimental)
JavaScript
2
star
30

jquery-html5-validity

JavaScript
2
star
31

imeveryone

Realtime anonymous communication platform
Python
2
star
32

solana-basics-for-everyone

The Keynote Presentation from my Solana Basics for Everyone presentation at Breakpoint 2023.
1
star
33

burn-everything-down

JavaScript
1
star
34

rolex

A better 'watch'
JavaScript
1
star
35

scalpels-and-aks

JavaScript
1
star
36

dotfiles

Mike's dotfiles.
Shell
1
star
37

staring_and_slurping

Starts/stops Soundcloud using the F5 key on your Mac
JavaScript
1
star
38

chrome-bluetooth

Chrome Bluetooth test
JavaScript
1
star
39

emptiness.js

JavaScript
1
star
40

formsed

A simple Chrome extension to quickly search/replace form data automatically when matched URLs are hit.
JavaScript
1
star
41

boring-config

Load a CSON config file
JavaScript
1
star
42

goodbye_horses

High performance CMS
JavaScript
1
star
43

london-javascript-events

List of all JavaScript events in London
1
star
44

minimal-messaging-extension

A minimal manifest v3 extension using chrome.runtime.sendMessage()
JavaScript
1
star
45

nodeplayground

A personal scratch playground for testing ideas in Node JS
1
star
46

quaderno-server

Helps calculate JSON web tokens (JWTs) for one-off charges in Quaderno.
JavaScript
1
star
47

rejectjs2013

Welcome our new ES5 Overlords
JavaScript
1
star
48

goodbye-horses

JavaScript
1
star
49

guetta

Adds additional David Guetta to websites
CoffeeScript
1
star