Default value of hidden input: fastest way to do it?

I have an input that is initially hidden on page load. Given that I am hoping for 10K+ users, I am trying to optimize for speed. The question is: Is it better to (1) set the default value to a value in the database or (2) to load the value in the database into a custom state on page load and then set the hidden input’s value to be the same as the custom state?

Although (1) seems more straightforward, I am wondering when the value is loaded into the input in that scenario. If it is when the input becomes visible, it’ll take some time to fetch the data. I’d rather all the fetching/searching happen on page load.

Advice is appreciated!

I think I have an answer. I tried both ways.

The second option is faster. When I make the inputs visible, their default values are immediately filled with the second option (loading from custom states) whereas they take a second to fill with the first option (have to search the database).