JS optimisation redux

An attempt at bringing https://github.com/moneyadviceservice/frontend/pull/301 into master.

I've filtered out the duplicate commits and merge conflicts as best I can and cherry-picked in the remaining though it'll need a close look at before merging.

@andrewtennison @alexwllms @aduggin @andrewgarner