On embedding Flash content using Web Standards (yes, again)

Lately there’s been a bit of buzz around embedding plugins while adhering to Web Standardsâ„¢. First this ALA article came out and said “bye bye embed”, then yesterday one of the WaSP nerds posted something about “Valid Flash, video and audio embed (object) markup”.

It’s understandable to want to try and force browsers to display your plugin content in a way that adheres to “Web Standards”. It’s a very popular subject, and it’s been covered a few times before. These two recent articles don’t uncover anything new, other than bringing to light (via the comments on them) that Javascript is the only viable method of embedding Flash (and other plugin based) content on the web today.

Now I’m going to say something here that might seem a little controversial, but I really want to get the point across, so I’m going to use some ‘shock and awe’ tactics:

Using only the object tag to embed your plugin content (especially Flash content) is fucking stupid.

There. I said it.

You may say that I’m a bit biased because I wrote some fancy pants Javascript Flash embed script. Maybe I have a hidden agenda of world domination based on plugin detection. So while I no doubt would like to dominate the world, let me say that my reasons for advocating the use of Javascript are much more mundane.

This post was originally going to be titled “Flash Satay considered harmful,” and since the main topic are these “Web Standards” compliant ways of only using the object tag to embed plugin content, I’ll focus on the issues with doing so:

  • “Click to activate” in IE. The only way to get around this is to use Javacript.
  • No plugin detection. While Ben says ‘meh’ to this, it’s a very important aspect of the user experience. If I have Flash Player 6 installed, and I visit a site that uses Flash 9 content, my player will go ahead and try to play that swf anyway. I could end up seeing half of the content, or broken content, or who knows what. Do you really want to show your users broken content?
  • Issues in older Safari versions: Safari pre 1.2 will completely ignore param tags, which are often used to pass information to the plugin. This means broken content for your users.
  • Support for the object tag varies widely from browser to browser. Do you think that just because you work around all the quirks in the 3 main browsers today, it will still work when the next new browser is released?
  • A bug in Flash Player 9 can cause the browser to crash if you have more than one swf on the page and are using ExternalInterface to communicate with Javacsript. While this isn’t specifically related to how the swf is embedded, SWFObject does include a fix for this issue.
  • Using Flash Satay or other ‘object only’ methods will not stream your Flash movies to the user – this means extra work for you in creating a ‘loader’ swf
  • JAWS will ignore it.

It’s a pretty long list, right? Now if you compare that to the user experience when using SWFObject (or other Javascript based techniques), you can see a noticable difference:

  • The only time a user doesn’t see Flash is if they have Javascript turned off, or they don’t have the required version of the Flash Plugin. This one is a two parter: One, do you think that people really turn off Javascript but leave Flash on? Consider the type of person who turns Javascript off. They are probably the über nerd user who considers anything that isn’t text to be completely evil. They browse the web using Lynx. They probably stay a mile away from the Flash Plugin anyway. The beauty of the way SWFObject works is that even these people get content if you set it up right. Since you put alternate content ‘under’ your swf, they will just see the alternate content. As long as you set it up right (you do, don’t you?) they may never even know they are missing out on Flash content.
  • They don’t have to click your movie once to ‘activate’ it
  • Their browser doesn’t crash just because you had two swfs on the same page that use ExternalInterface
  • They only see Flash content if their browser and plugin support it.

Taking all of the above into account, the choice is very clear: Javascript wins hands down. Any questions?

Now that all of that is taken care of, I wanted to address a couple of things:

First, these types of posts are not good for the Web Standards community. Basically what’s happening is highly visible people (even if they aren’t that well known, they still carry the WaSP name, or have articles on well respected online publications like A List Apart) are posting information that is bad for your users. Even worse is that they are doing it in the name of “Web Standards” and not taking into consideration any of the other options outside of pure HTML. This is extremely bad for the Web Standards movement. It makes the standards advocates look like crazed zealots who don’t care about user experience, but only care about adhering to the written rules exactly how they are stated even if it hurts them.

Second, you may be saying “well, if I can’t use the object tag, then what good is it?” and that is a FANTASTIC question. What good is it? Beats me, because the object tag is completely and utterly broken in nearly every web browser out there. Want to do something about it? Maybe you could join WaSP and create a task force to fix how browsers handle plugins?

UPDATE: I added this as a comment below, but wanted to put it in the main post as well: I want to say that as for Flash Satay: It was fantasic for the people who use(d) it, and in it’s time it was great. But now that certain big issues with it have been discovered, and Flash has changed over time, it’s time for it to retire. This is something I’ve been meaning to mention for a while, and it was sort of implied on the SWFObject page. So, since we are on the subject, it’s time to give it up.

UPDATE (8-17-2006): Ben has posted a follow up.

SWFObject 1.4.4 released

There was a new bug intruduced in the 1.4.3 release of SWFObject, so if you are using 1.4.3, you should upgrade to 1.4.4 immidiately.

The issue is that onbeforeunload is being triggered even when a user clicks a link that contains a javascript link, which causes the cleanup routine to trigger, which makes all your swfs on the page dissapear in IE.

This has now been fixed, and 1.4.4 includes all of the ‘fixes’ that are needed to date, including the streaming media fix, and the Flash Player 9 ‘out of memory’ errors.

Download Now

* One new issue that can arise with the addition of the cleanup routines, is if you are including the swfobject.js script in your pages more than once, you will cause more ‘out of memory’ errors. If this happens, make sure you only insert the swfobject.js file in your page only one time.

SWFObject 1.4.3 released

Please note that there is an issue with this version of SWFObject. When clicking links that use href=”javascript:” in them, it triggers the new onbeforeunload, which makes all your swf files dissapear. All users should upgrade to 1.4.4.

This release only contains a single fix for a new issue that occurs when using Flash Player 9.

If you have multiple swf files embedded in a single HTML page, and at least one of those files uses ExternalInterface to add a callback, when you leave the page you will get an error that says “Line 56: Out of Memory”.

This only occurs in IE – no other browsers are affected, and it only happens when using Flash Player 9 whether you are using SWFObject or not.

The problem is in some new Javascript code that was inserted into Flash Player 9 to fix a bug in the IE browser. This IE bug affected swf files that connected to streaming media servers – to learn more about it you can read this blog post.

After working with Adobe, we came up with a Javascript fix for the streaming media issue and I used a variant of this code in the 1.4.2 version of SWFObject. All was fine then, until Flash Player 9 was released, and it turns out Adobe included their own Javascript (that is very similar to the fix in SWFObject) to fix the streaming media problems in IE. The only problem is that the code they used doesn’t like it when there is more than one swf embedded in a page.

So to get to the point, this new version of SWFObject just removes the ‘bad’ code that Flash Player 9 inserts into the page and instead uses the cleanup code from the previous version of SWFObject that has been working fine for Flash Player 8.

Go grab a copy now – anyone using ExternalInterface needs to be aware of this issue and should upgrade their SWFObject script immediately if you have any pages with more than one swf embedded in it.

Here’s a direct download link, or you can get it out of the SVN repository, or visit the SWFObject page and get it from there.

Adobe user group meeting tonight in NYC

Schematic will be hosting the first of many Adobe User Group meetings tonight at the NYC office. If you are looking for something to do, stop on by. There will be two presentations:

  1. 7-8pm: Simulating Physics with Flash by Alec Cove
  2. 8-9pm: OOP Animation with Fuse by Roger Braunstein

The meeting will take place at 41 E. 11th st, 6th Floor at the Schematic NY office. The entrance is on 11th St. just east of University.

More information can be had on the AUG website.

Speaking at Flash on the Beach

Flash on the Beach is a new Flash conference this December in Brighton Beach, UK. I’ll be heading out to give a SWFObject presentation. I’m really excited about this one – it’s got a bunch of great speakers lined up already and they are still adding more every day. This will be my first time speaking at a conference over seas*, so I’m super excited about that as well.

* The OFFF festival flew me out to barcelona in 2001 to show some Flash creatures, but I didn’t give a presentation, they were just hanging out in one of the side rooms.