Browser Dependency Checker JavaScript Library

Browser Dependency Checker

Introduction

Browser support is more and more important as web technologies are fast growing. New CSS rules and JavaScript functions are developed and there is differences between how web browsers behave. It is also important to keep older web browsers supported. This small library I wrote will help you determine what’s the lowest supported web browser version and display a popup.

Browser Dependency Checker is a JavaScript library that helps you to determine the lowest allowed version to display your website without any issues.

Loading the library

We can get required library from it’s Github’s page.

We need to either download or use libraries hosted on GitHub:




<script src="https://raw.githubusercontent.com/marncz/browser-dependency-checker/master/browser-dep.js"></script>
<link rel="stylesheet" href="https://raw.githubusercontent.com/marncz/browser-dependency-checker/master/browser-dep.css">

Using Browser Dependency Checker

Get minimum version

This function will check present CSS rules and return minimal required version per web browser.


// Get lowest version of Chrome needed to view current page - without debug mode
getMinBrowserVersion( "Chrome", 0 );

// Get lowest version of Firefox needed to view current page - with debug mode
getMinBrowserVersion( "Mozilla", 1 );

Restricts users with version below given

You can also set your own values and select action after met / failed requirement.



// Users need to have Chrome version >= 48 OR Firefox version >= 5
browserDepCheck ( { "Chrome" : 48, "Mozilla" : 5 } );

// Redirect on failed requirement
browserDepCheck ( { "Chrome" : 48, "Mozilla" : 5, "fail": "/failed" } );

// Redirect on success
browserDepCheck ( { "Chrome" : 48, "Mozilla" : 5, "sucess": "/ok" } );