Skip to content

Blog

JavaScript and Flash comparison

Author: Simon Jackson

It used to be so simple - when you wanted to add something more, well, flashy to your website you used Flash. Where JavaScript was clunky, no good at transitions or animation and was riddled with cross-browser inconsistencies, Flash was smooth, presentation rich and as a plug-in was consistent across browsers. However, with the advent of frameworks such as MooTools and jQuery and increasing browser functionality, the decision is no longer straightforward. Perhaps now the starting point when implementing a whizzy feature should be 'why can't we use JavaScript?'.

Statistically speaking

Whilst it's difficult to ascertain accurate figures for both the install base of Flash and the number of browsers with JavaScript enabled, it seems that most sources agree both are available to 90-95% of users. In both instances, it is most likely to be large corporations with locked down internal networks that block both the execution of JavaScript and the installation of 3rd party add-ons. Bearing this in mind there is no in-built advantage in terms of market penetration for either of the two protagonists.

Accessibility

Another area of concern with both methods is the accessibility of content. Flash has a reputation for being rather flaky in this area, but in a lot of instances this is due to lazy production techniques. By the same token, whilst JavaScript manipulates standard HTML, badly-written code and CSS can still obfuscate the accessibility of content.

However there does remain an underlying issue with Flash and its proprietary behaviour - user interface basics such as the back button and standard page loading cues are potentially lost where users expect them. Whilst JavaScript (specifically in conjunction with AJAX) can also suffer from these issues they are much less likely to occur and the default behaviour and accessibility of browsers is more likely to prevail.

Graceful Degradation

If your users do not have JavaScript or Flash installed what are the alternatives? Both methods have the ability to supply alternative content to users, but there is an inherent downside for Flash developers in that the alternative format is completely alien to the Flash development. For instance, if data is being supplied to the Flash file from a database or XML source and you are implementing a genuine fall back, this means writing a solution in a back-end process to extract the same information for presentation as HTML.

The immediate advantage that JavaScript has is that it takes standard HTML as its data for manipulation in the user's browser. This means that the process used to present this data can also be used to supply the fallback presentation.

The advantage of this to your users is that the non-JavaScript alternative is much more likely to stay in sync with the JavaScript presentation - with much less effort from the developer.

SEO

Search engine optimisation is one area where JavaScript wins hands down. As long as the code used to supply the content is standard HTML then search engines can analyse it with ease. Flash does provide SEO capabilities, but this places the onus on search engines to be willing to delve into the Flash mechanisms to ascertain the relevant content.

Applications

Complex animation and video players remain the most obvious reasons to use Flash and JavaScript simply cannot compete in that regard. Whilst HTML5 will reproduce these features directly in-browser this is not currently an option. Where frameworks such as MooTools have caught up with Flash is in the domain of slideshow-style transitions, slides, opacity etc. This type of functionality is well suited to JavaScript as the code is lightweight and in many cases the non-supported fall back is often much easier to implement.

Conclusion

The number of applications where Flash is still a de-facto choice is shrinking and will continue to shrink with the adoption of HTML5. As mentioned earlier video, complex animation and other types of functionality that the underlying browser technology does not support is its stronghold and JavaScript does not at the moment provide a viable alternative.

On the other hand, JavaScript with its lightweight implementation provides the best solution for adding "bells and whistles" to websites and online applications. The graceful degradation of these "bells" is easier to implement and, critically, if the content contained within is SEO critical then JavaScript is the obvious choice.