Engineering Decisions · Junior · Question 1 of 12

A server-rendered site lets guests pick a dark theme. The very first HTML must already use the right theme, with no flash. Where do you keep the choice?

Show the answer

Correct answer: In a cookie the server reads on each request

Explanation

Only a cookie reaches the server with the request, so the HTML can be rendered in the right theme straight away. localStorage fits client-only apps, or if a small inline script may set the theme before paint. A database table fits signed-in users who want the setting on every device, but guests have no account.

Further reading

Problem with a question

Engineering Decisions · Junior · question 1

Test yourself

Take the Engineering Decisions · Junior quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz