flash + javascript & providing alternative content
di piko! (del 07/12/2007 @ 09:56:40, in _muy felìz :., linkato 1889 volte)
something i feel that is extremely important is graceful degradation (or progressive enhancement, if you prefer). essentially what that refers to is marking up a document in such a way where any reader would have no idea they may or may not be having a different experience than someone else while at a particular site. what could cause one reader to have a different experience than the next? one thing could be whether or not a specific browser plugin is installed (flash, for example) or if a specific technology were enabled (javascript, css).

of course there are many things that can’t completely gracefully degrade, but it’s still important that those things don’t totally fail and/or ‘break’ your page. their inclusion should be as transparent as possible to your readers. worst case scenario could be that you provide your reader with a message that the particular document requires javascript to operate and that you must have a javascript-enabled browser to use it. in the case of flash, instead of the ugly ‘browser plugin needed’ sections that may overlay your intended swf, you could provide a more graceful notification to your reader and provide a link to download the latest flash player.

how do you provide alternate content?

many articles have been written on the best way to provide alternate content. the various methods have their pros and cons as always. i have my personal choices for which technique to use as i’m sure you do too. what i’d like to do is bring up the methods i’m currently using, and leave the floor open for critiques and suggestions based on your personal methods.

flash: unobtrusive flash objects and swfobject

there has been much debate over time as to which method for including flash is best. andrew kirkpatrick posted quite a lengthy writeup comparing various techniques that is worth a read. of all the techniques, i lean towards unobtrusive flash objects. i was first introduced to ufo by a co-worker some time ago, and personally think it’s the way to go when it comes to including a flash piece into your website. ufo is best defined by its author:

    ufo is a dom script that detects the flash plug-in and embeds flash objects (files with the .swf extension). it has its roots in the web standards community and is designed to support w3c standards compliant, accessible and search engine friendly web design. it also contains several features and best practice techniques that other scripts currently don’t have. ufo is free, licensed under the cc-gnu lgpl and an open source flash project.

the ufo site offers a large amount of information regarding why you should use something like ufo over previous methods of including flash in documents. it is an extremely comprehensive solution and in my opinion, the best one out there. not only does the script detect the presence of flash, you can designate which version of flash your swf is using as to not display a partially functioning flash piece to your readers.

there’s also swfobject (formerly flashobject)

another method for progressively enhancing your document with a flash movie would be swfobject (formerly flashobject). essentially swfobject and ufo do the same thing; they use a combination of javascript and xhtml to provide plugin checking and swf inclusion. it may be because i was introduced to ufo first, but i prefer using it to swfobject. they each sport a slightly different syntax, but operate in a very similar fashion.

internet explorer benefits

whether you decide to use ufo or swfobject, the benefits for internet explorer alone should be quite desirable. as you probably know, internet explorer now provides what is referred to as an active content update which is an invasive technique requiring a user to make an extra click in order to enable a variety of technologies, flash being one of them. both ufo and swfobject act as ‘workarounds’ to this, and can provide a beneficial experience to your reader.

fallbacks to the technique

with just about every pro there is a con, and this situation is no different. as you can see, the technique depends completely on the presence of a javascript enabled browser. some people would find this limiting in and of itself, because flash is a completely different technology and it is entirely possible for a reader to have the flash plugin installed and browse with javascript disabled. in my personal opinion, the dependence on javascript should be looked at as a positive. not only can it detect whether or not a reader has flash installed, it can determine which version of flash they have too. those benefits alone, for me, outweigh a reader seeing the ‘missing browser plugin’ dialog on any browser.

graceful degradation of javascript

graceful degradation with javascript, i think, takes a bit more thought. with flash, it’s basically a matter of creating your swf, providing it a container in your markup (along with your alternate content), and then including ufo (or swfobject) with the correct parameters. the script takes care of the rest. with javascript, it’s a different ballgame. as the developer, you need to put some thought into how things are going to work. you need to put some time into testing with javascript disabled to ensure that all of your visitors have the best possible experience.

javascript methodologies have come such a long way, and there are many ways to ensure that your scripts gracefully degrade. there have been entire books written on the subject that offer completely great advice that should be taken into consideration by any web designer/developer. each case will be different in appropriate alternate content to provide, and some thought should be put into each one. if javascript isn’t completely essential, don’t tell your user that the page requires javascript. re-examine what the page is doing and compensate if you need to. just because ajax (yes, real ajax) is the latest buzzword doesn’t mean you should break things just to say you use it.

in conclusion

the point i’m trying to make is that in this era of ever advancing web technologies, it’s still extremely important to provide alternate content. readers come first, above your javascript animations and flash movies. while it’s completely great to offer those enhancements, there is a lot you can do to make sure a reader isn’t faced with any barriers when it comes to a site you put together. in the end, as always, it’s up to you.