No code here, just a gif showing MapShaper.
Step 1: Upload a GeoJSON to MapShaper. Try this one.
Step 2: Experiment with the different simplification algorithms, use the slider to choose how simplified you want your shapes, and watch for the number of line intersections that occur.
Step 3: Export your file as a topojson.
https://d3js.org/d3.v4.min.js