Minimal Browser Feature Detection In Pure JavaScript – BrowserFeatures.js

Category: Javascript | July 4, 2018
Author: BaseMax
Views Total: 207 views
Official Page: Go to website
Last Update: July 4, 2018
License:

Preview:

Minimal Browser Feature Detection In Pure JavaScript – BrowserFeatures.js

Description:

BrowserFeatures.js is a small JavaScript library for browser detection that tells the user whether particular features are supported by the current browser.

See also:

Features to detect:

  • function_generator
  • function_async
  • function_generator_async
  • event_target
  • data_transfer_item
  • data_transfer_item_list
  • broad_cast_channel
  • Viewport
  • Font
  • custom_element
  • Animate
  • SVG
  • Touch
  • WebGL

How to use it:

Download and import the minified version of the BrowserFeatures.js library into the html page.

<script src="BrowserFeatures.min.js"></script>

Detect the browser features and return true of false if supported/not supported.

window.addEventListener("load",function()
{
  //browser.function_generator
  document.write("<b>" + "FunctionGenerator" + "</b> : " + browser.function_generator + "<br>");
  //browser.function_async
  document.write("<b>" + "FunctionAsync" + "</b> : " + browser.function_async + "<br>");
  //browser.function_generator_async
  document.write("<b>" + "FunctionGeneratorAsync" + "</b> : " + browser.function_generator_async + "<br>");
  //browser.event_target
  document.write("<b>" + "EventTarget" + "</b> : " + browser.event_target + "<br>");
  //browser.data_transfer_item
  document.write("<b>" + "DataTransferItem" + "</b> : " + browser.data_transfer_item + "<br>");
  //browser.data_transfer_item_list
  document.write("<b>" + "DataTransferItemList" + "</b> : " + browser.data_transfer_item_list + "<br>");
  //browser.broad_cast_channel
  document.write("<b>" + "BroadCastChannel" + "</b> : " + browser.broad_cast_channel + "<br>");
  //browser.viewport
  document.write("<b>" + "ViewPort" + "</b> : " + browser.viewport + "<br>");
  //browser.font
  document.write("<b>" + "Font" + "</b> : " + browser.font + "<br>");
  //browser.custom_element
  document.write("<b>" + "CustomElement" + "</b> : " + browser.custom_element + "<br>");
  //browser.animate
  document.write("<b>" + "Animate" + "</b> : " + browser.animate + "<br>");
  //browser.svg
  document.write("<b>" + "SVG" + "</b> : " + browser.svg + "<br>");
  //browser.touch
  document.write("<b>" + "Touch" + "</b> : " + browser.touch + "<br>");
  //browser.webgl
  document.write("<b>" + "WebGL" + "</b> : " + browser.webgl + "<br>");
});

You Might Be Interested In:


Leave a Reply