Rebuilding United Website - Development Workflow
4 minutes read
About three weeks ago Ben Chalk and I were asked to redesign and rebuild the United website. It hadn't been touched in months and badly needed an overhaul. It was a very basic single page with information on clients, services and contact details. The plan was to keep that content, add a section for United's work and case studies, give it a fresh new look, and make it more accessible and easier to use. This is what we started with:
Design and wireframes
Being responsive was a big part of the overhaul, so Ben designed mobile first. We brainstormed over a few mockups and wireframes and agreed on one. Ben then turned the wireframes into the first full visual design, and once we were happy with it the project moved into development.
Development
Development was mobile first too. Twitter Bootstrap handles fluid layouts well out of the box. To check the layouts on as many devices and screen sizes as possible, I used two testing tools:
The Chrome emulator covers lots of devices. Resizer has a long list of screen resolutions and lets you add your own.
There wasn't much content and none of it needed to come from a CMS or database, so I used Jekyll to build the pages. Jekyll also has a local server for testing. I used Grunt.js to automate the rest of the workflow. Grunt plugins handled:
- Optimizing and compressing the images
- Concat SASS files from various packages i.e. Bootstrap, Animate.css, IcoMoon
- Concat, compress and minify the JavaScript packages
- Contents delivery using Jekyll with Grunt
- Watching the file changes automatically to run appropriate tasks
Sass lets you customise packages without touching their core code. It also combines several Sass files into one, lets you reuse variables and functions, and compresses and minifies the CSS for production.
Bootstrap Sass lets you pick which modules a project needs. Comment out the ones you don't and their CSS stays out of the production file, which keeps it smaller.
Don't include a whole library for a few functions. Take only what you need.
Merging the CSS into one file also saves HTTP round trips.
I did the same with the other frontend tools in the project: jQuery, jQuery Mobile, Animate.css and Bootstrap.js. For the social media links I used a small set of icons from IcoMoon, again importing only the glyphs I needed instead of a whole font file.
The point of all this picking and choosing is to keep file sizes down and the site fast.
Instagram and Twitter feeds
The contact section has feeds from Instagram and Twitter channels.
Instagram feed
The Instagram API now makes it easy to get a user's feed, thanks to a new addition to its /users endpoint. I fetched it with jQuery.getJSON, as below. The callback=? parameter returns JSONP, which gets around the cross-origin restrictions on XMLHttpRequest.
var url = 'https://api.instagram.com/v1/users/396527045/media/recent/';
url += '?client_id=012345689';
url += '&count=10';
url += '&callback=?';
$.getJSON(url, function (data) {
// Setup Instagram feed here.
});
Twitter feed
The Twitter API needs OAuth, so I used Fetchwitter, my PHP library that handles the OAuth side for you. An XMLHttpRequest to Fetchwitter, much like the example above, returns JSON. The tweets come back as plain text, so they need formatting.
Fetchwitter has a built-in to_tweet method that turns plain text into a proper tweet with links, hashtags and mentions. Since the data was already arriving as JSON, it was easier to format it on the frontend, so I added a few methods to JavaScript's String prototype that do the same job. They use indexOf, which Internet Explorer 8 doesn't support on arrays, so I also had to patch the Array prototype for IE8. Here's the result:
See the Pen Format text to tweet using JavaScript String prototyping by Jabran Rafique (@jabranr) on CodePen.
The JavaScript is in the JS tab, and on a Gist.
Animations
I care about usability and accessibility, so I start with the simplest technology that works for most users in most browsers, then add to it with progressive enhancement, keeping graceful degradation in mind. Animations came last. We wanted a subtle parallax effect on scroll. onscroll is an expensive DOM event, so to keep its use down I used jQuery with Animate.css, a great collection of CSS3 animations. The Fading Entrances and Fading Exits modules give an eased parallax effect as you scroll down. Once you reach the last section and the animations have run, they're switched off.
Visit new website at http://united-agency.co.uk!
Updated 11-06-2014: added details on the animations to the last section.