March 2, 2024
Every client theme I build uses a base theme, but it's not always the same base theme and for various reasons they don't always have the same breakpoints. I've always been a little bit bothered by having to duplicate breakpoints in JavaScript because it feels redundant and a potential source of future issues / inconsistency—on multiple occasions I've inherited sites where the breakpoints aren't consistent across CSS and JavaScript, leading to unexpected behaviour at certain browser widths. My solution to this has been to start including the breakpoints as JSON in the HTML source so that any JavaScript that needs them can find them there rather than having them hardcoded in the script itself.