A question: if you had the choice of three websites: one static, one with badly done animation, and one which has been enhanced with subtle use of animation, which would you choose? Well, my hope is the answer to that question should be number three: animation can really make a site stand out if done well, or fail miserably if done badly!
So far, our content has been relatively static, save for the use of media queries. It's time, though, to take a look at how PostCSS can help make animating content a little easier. We'll begin with a quick recap on the basics of animation, before exploring the route to moving away from pure animation, through to SASS, and finally, across to PostCSS. We will cover a number of topics throughout this chapter, which will include:
A recap on the use of jQuery to animate content:
Animate.cssLet's make a start…!
Animation is quickly becoming king in web development, more and more websites are using animations to help bring life and keep content fresh. If done correctly, they add an extra layer of experience for the end user; done badly, and the website will soon lose more custom than water through a sieve!
Throughout the course of the chapter, we'll take a look at making the change from writing standard animation, through to using processors such as SASS, and finally, switching to using PostCSS. I can't promise you that we'll be creating complex JavaScript-based demos such as the Caaaat animation (http://roxik.com/cat/—try resizing the window!), but we will see that using PostCSS is really easy when creating animations for the browser.
To kick off our journey, we'll start with a quick look at the traditional animation—how many times have you had to use .animate() in jQuery, over the years? Thankfully, we have the power of CSS3 to help with simple animations, but there was a time when we had to animate content using jQuery.
As a quick reminder, try running animate.html from the T34 – Basic animation using jQuery animate() folder. It's not going to set the world on fire, but is a nice reminder of times gone by, when we didn't know any better:

If we take a look at a profile of this animation from within a DOM inspector from within a browser such as Firefox, it would look something like this screenshot:

Whilst the numbers aren't critical, the key point here is the two dotted green lines, and that the results show a high degree of inconsistent activity. This is a good indicator that activity is erratic, with a low frame count, resulting in animations that are jumpy and less than 100% smooth.
The great thing, though, is that there are options available to help provide smoother animations; we'll take a brief look at some of the options available, before making the change to using PostCSS. For now though, let's make that first step to moving away from using jQuery, beginning with a look at the options available for reducing dependency on the use of .animate() or jQuery.