Tiny (<1k) Flash detection script distilled from SWFObject
npm install flashdetectflashdetect
===========
Tiny (<1K) Adobe Flash® Player detection script distilled from SWFObject
Use
---
Include or load flashdetect.min.js, then call getFlashVersion(). This will always return a number:
* If the Flash Player plugin is installed, a number denoting the major and minor version is returned, e.g. 9.125 or 11.8
* If no Flash Player is installed, -1
This usage allows for easy, clean evaluation, like so:
AMD
---
If you roll with the cool kids and use a module loader like requirejs, use the flashdetect.amd.js file. The closure will return a function, so you can just do:
require( ['flashdetect.amd'], function(getFlashVersion){
if( getFlashVersion() >= 9 ){
// Go to town!
}
});
Objective
---------
The goal here is reliable and simple cross-browser Flash detection in as little code as possible.
getFlashPlayerVersion() method returns an object with more detail than is usually needed. Flashdetect always returns a number, so you can more easily pop into an evaluation as described above.The minified version of this script is about 600 bytes.
What's changed
--------------
Only the vital bits of SWFObject's original detection are retained. Here's what's changed:
* The 'release' number is gone (3rd value after major & minor versions).
* Detection via the object element for non-IE browsers is not carried over. See testPlayerVersion() in SWFObject's source for more info.
* Repeated references and Strings are abstracted to variables for better minification.
* 'undefined' and null tests are replaced with !!, since all the values are expected as objects.
* Regular expressions were consolodated.