Context is a single page app with a rest backend.

For things like state and city lists, which rarely change, is it better to store them on server and load from client, or store them directly on client as javascript objects?

I am in favor of putting them on client to avoid writing boilerplate code (things like when state is selected city combo will be filled from server etc), but don't know if there's a downside.

  • 1
    There are 19,354 cities in the United States. You want to download that every time you load a page?
    – John Wu
    Commented May 22, 2018 at 3:35
  • 1
    This is a caching question. You need the server information but how long will you want to hang on to the result. Commented Nov 18, 2018 at 12:16
  • 1
    This is a question which falls into the bow vs tie category of questions and the answer to that is: depending on the circumstances the one or the other is wrong. There are several possible solutions, including all on the client, none on the client, some of the client and some not. Without knowing how customers use your application it is hard to tell. Commented Dec 13, 2019 at 18:15

2 Answers 2


These two fields are related, so a dropdown list of cities would be filled dynamically based on the state. The structure for that would be easier to store in two database tables on the server side rather than reinventing the wheel on the client side. In addition, if you need to prefill the city and state based on a zip code, storing them on the server is better since you there's a many-to-many mapping required is much easier to maintain in a relational database.



I'd see it as a balancing act, and I'd orient it around user experience and hardware load, not code, you've got two choices;

  1. Load cities from server each time user clicks. [Fast first load, Laggy during use]
  2. Filter cities client-side. [Long first load, Fast during use]

You may also need to consider the computational expense of whatever you're doing, it may even run faster on a server...

Only you can answer this really;

  • User Experience Requirements
  • Hardware Load Requirements
  • Coding Expertise Requirements

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.