Responsive design

It’s rare nowadays that we get any project that isn’t going to be responsive, so in all likeliness, you’re going to be coding one. There’s plenty of stuff on the web already about how to do responsive design properly, so we’ll just talk about how we do it.

We are mobile first. This means we build things for small screened, low-capability devices first before progressively adding functionality and ever-larger images for higher power devices. Mobile first has a tonne of advantages:

CSS breakpoints should be mobile first, with breakpoints for larger resolutions afterwards. If you still need to support a browser that doesn’t support media queries (may god have mercy on your soul) then use feature detection to serve those browsers different CSS.

JavaScript which only applies to certain breakpoints should be initialised on that breakpoint. Use something like matchMedia to determine the user’s screen resolution and conditionally initialise or destroy JS functions.