Task Runners
Task runners are programmable scripts that automate development processes
I want to compare how much improvement task automation can have on front-end development tasks I do routinely.
The goal of my routine tasks are:
- Cross-device support
- Bootstrap
- jQuery
- Plugins etc.
- Faster page load
- Minify HTML, CSS, JavaScript
- Manage page size
- Multiple pages with consistent features e.g. navigation
- Testing
- BrowserStack
- Litmus
Task breakdown
Let’s break these down into goals into the tasks that I must do.
Cross-device and feature support
- Setup project directory and sub-directories
- Find the download URL for the file version
- Add the file to a project
- Add file dependencies
- To update or change any file version repeat steps 2 – 4
Faster page load
- Compress HTML, CSS, JavaScript, images and other assets
- Minimize file downloads by concatenating files i.e. send all CSS in one CSS file
Multiple pages
- Use templates to write features once and include it where it is needed
Testing
Browserstack (page testing)
- Upload images and files to an external FTP location
- Access URL with Browserstack
Litmus (email testing)
- Inline-CSS
- Upload images to an external FTP location
- Update images with FTP location URL
- Generate email
- Send to Litmus
The case for automation
The benefits of automating these steps are:
- Use reliable automation to achieve consistent quality workflows
- Workflows can be shared and customised
- Benefit from the works of others
So I can accomplish the same tasks using task runners by:
- Scaffold with Yeoman.io
- Build with Grunt or Gulp
- Manage dependencies with Bower
Steps
Setup
- Install Yeoman.io (once)
- Use Yeoman template appropriate to the project
- Use Bower to manage project dependencies
For faster page loads
- Use SASS or LESS for CSS so files can be imported into one main file
- Install gulp
- Define gulp task
- Run gulp task
Templates
- Run gulp task
Testing
- Run gulp task, especially for unit and end-to-end tests
Case study: Email testing
The process for testing emails is a well-defined business process and so allows us to make some basic, time-based comparisons.
Comparison
These are the approximate time comparisons for manual vs. automated approaches in seconds
Upload images to a publicly accessible location
- Manual: 60 seconds
- Automated: 20 seconds
Replace image links in email
- Manual: 20 seconds – Automated: 0
Generate an email and send it to Litmus
- Manual: 210 seconds – Automated: 0
Total time
- Manual: 290 seconds
- Automated: 18 seconds
An automated process shows a 16x time improvement and so can be scaled to include additional requirements.
Examples of task runners
- Static site generators – Middleman, Harp, Hugo
- HTML5 web apps – Ionic, Reapp, Angular
- Online web applications scaffolding – Yeoman.io, Play framework
Bibliography
Next steps
Automating language translations
Subscribe to my newsletter
Read articles from Peter Banjo directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
Peter Banjo
Peter Banjo
I build meaningful software by empathising with design, development and business needs. My interests are test automation, functional programming and full-stack web development using NodeJS and other tools.