SBC Games wrote a series of tutorials on building games that are easy to maintain: "Many tutorials show you how to build a game. Let’s say, you already have one. And because it is good and catchy, sponsors are interested in it. Your nice and clean code is step by step polluted with sponsor specific APIs.
In this part of series, we will add code to save and load user settings. In browser you can use LocalStorage for this. But we will think ahead a little and prepare our saving/loading infrastructure for other types of storages. Some game sponsors have their own storage and we also want to work, for example, with Facebook Instant games API."