npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

flashdetect

v1.0.0

Published

Tiny (<1k) Flash detection script distilled from SWFObject

Downloads

37

Readme

flashdetect

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:

<script src="js/flashdetect.min.js"></script>
<script>
	if( getFlashVersion() >= 9.125 ){
		// Flash approach
	} else {
		// Non-Flash approach
	}
</script>

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.

Reliabile:

The original detection code comes from SWFObject, a Flash embedding library that's been thoroughly vetted and widely used for years. Really, the SWFObject contributors did most of the hard work here and deserve commensurate credit.

Simple:

SWFObject's 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.

Small:

If you're not sure whether a browser supports Flash, you don't want to load a 10k+ (minified!) script just to find out. What's more, we use Flash in different ways than we used to: mostly for polyfills and enhancements like ZeroClipboard. These libraries tend to come with their own streamlined embedding code, and you may not want to load the polyfill unless you know it's supported.

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.