mootools/mootools-core — Issue #2206: Flash detection // Performance Issue
Author: ibolmo
Created: 2012-01-19 06:50:27+00:00
State: open
Labels: enhancement, optimization

(from [Lighthouse](https://mootools.lighthouseapp.com/projects/2706/tickets/1267-flash-detection-performance-issue)).

The Flash detection should be transformed in an "on-demand" method.

In IE Browsers you lose some seconds on initialization, and you really don't need to do the check by default.

so, here is my proposal:

``` javascript
(function() {

var version;

var detect = function() {
if (!version) {
version = (Function.attempt(function(){
return navigator.plugins['Shockwave Flash'].description;
}, function(){
return new ActiveXObject('ShockwaveFlash.ShockwaveFlash').GetVariable('$version');
}) || '0 r0').match(/\d+/g);
}
return version;
}

Browser.Plugins.Flash = {
version: function () { return Number(detect()[0] || '0.' + detect()[1]) || 0 },
build: function () { return Number(detect()[2]) || 0}
};
})()
```