Converting GeoJSON to PNG
Within the United Kingdom there are approximately 650 constituencies, which makes for a highly detailed map. A detailed map means a larger file size and therefore more heavy processing on the client side, so when building the UK Political Atlas we needed a solution that wouldn’t slow down client-side rendering when exploring different constituencies.
We decided on an offline approach of rendering each constituency with d3-node (which allows for static rendering with the power of d3) and then converting the rendered SVG into a PNG with sharp. Within one minute, we had 650 static PNG files of ~7kb each; compared to the 6mb GeoJSON file with which we started. Now when a user loaded a constituency detail page the browser only had to retrieve a single small file and the page would load fast even on mobile or older browsers.