CSS Animation vs. Video: Should We, Not Could We
Join the DZone community and get the full member experience.Join For Free
last week i was asked to evaluate the technical impact of transferring a (rather simple) animation to html5 and css3. so i searched around, looked at some css3 animation demos and figured that with a few minor adjustments it wouldn't pose any real technical challenge. before i finalized my answer i waited a minute to reconsider the problem, as it felt as if i had somehow missed the most essential part of the question.
the company i work for wanted an animation visualizing and explaining its main ideology (define - design - realize - optimize). there was a story board detailing the different objects, animations and links between objects. the animation was kept pretty basic (nothing organic, just simple mathematical animations) and thus html/css was considered for the implementation. not in the least because it would also we a great showcase of our front-end skills.
technical challenges aside though, the real question was whether this animation would actually be a valid use case for html/css animation. after all, it's not because we could do it with html/css that we should do it. i was instantly reminded of the time people made simple websites in flash (just because they knew how to use the tool) and that was clearly not the message we wanted to send to our potential clients. it wasn't just about showing our technical proficiency, it was also about motivating we could use the right tool for the right challenge.
css animation vs video
before making any final claims about the challenge i was given, i had to figure out the differentiating factors between video and css animations. while there is definitely a gray area between the two solutions, there are also some good differentiators that will help us choose between the two.
a video is mostly presentational. it gives you a nice and guaranteed aesthetic experience, possibly (but by no means a given) also some actual content. on the other hand, video isn't all that semantic and doesn't allow for much interactivity without hacking yourself a way around a myriad of limitations. style is clearly more important than content.
the problem with css animation is that quality isn't guaranteed. depending on the processor load, machine power and complexity you might end up with a stuttering presentation. on the other hand, you can create a semantic equivalent of your animation so it becomes more than just a sequence of visual frames. you can actually unlock your story to people who aren't able to watch the animation itself.
using the differentiators
if presentation matters most then i would definitely opt to use video. there aren't as many limitations and quality playback is more or less assured. on the other hand, if you want interaction and/or you benefit from making a semantic equivalent of your animation than html/css becomes a viable option.
back to the real world
of course this is a very theoretic approach to the problem. there are other factors that may influence your final decision, but they are variables rather than best practices and they are sure to change over time. it's not that they are not important, in some cases they can actually be critical, but they shouldn't be your primary concern when faced with this kind of choice.
file size, streaming possibilities, fall-back mechanisms and responsive behavior need to be taking into account and can still overthrow your initial choice. that's okay, as long as you can use them to motivate your choice when going against standing best practices. just picking a method because it's what you do best or because it's cool and everyone is doing it these days on the other hand is lazy and just plain stupid.
currently we are still investigating the fall-back quality in browser who don't support css animation. if these tests guarantee us a sufficiently high quality we'll be starting the development of our html/css animation. i have a pretty good idea of how to go about this, so hopefully i'll be able to share a demo in the near future.
the bottom line of this article is not so much about video and css animation though, it's about considering the tools you use for certain challenges, first and foremost thinking about what a tool is supposed to be doing instead of what would be easiest for you to develop. there are always real-world factors that might influence your original decision, urging you to go against what you know is right, but that's probably what separates professionals from amateurs.
Opinions expressed by DZone contributors are their own.