Skip to main content

This blog post was published under the 2010-2015 Conservative and Liberal Democrat coalition government

https://mojdigital.blog.gov.uk/2013/11/04/modular-javascript-with-heisenberg/

Modular JavaScript with Heisenberg

Posted by: , Posted on: - Categories: Development

Organising JavaScript in a small project is like choosing what to eat in a restaurant - there are lots of options, the only person it's really going to matter to is you, and you can always try something different next time. But when you're working in a team on projects with long lifespans that will need to be maintained by others, consistency is essential.

To this end, when beginning to assemble what will eventually become the MOJ Front-End Toolkit we needed to decide on a pattern for including JS files and modules in our sites, so as a starting point we selected Heisenberg.js. It's not a framework or library in itself, but a pattern/methodology for organising your files and we're liking it so far. It provides a defined structure for each module and a standardised way of including modules in our projects. We're not using the whole Heisenberg project, just the module structure, and to further strengthen the idea of consistency we're also using a slightly amended coding style from Idiomatic.js.

If you'd like to know more, the addendum to this post breaks down the JS with an actual example.

Sharing and comments

Share this page

Leave a comment

We only ask for your email address so we know you're a real person

By submitting a comment you understand it may be published on this public website. Please read our privacy notice to see how the GOV.UK blogging platform handles your information.