We currently fetch temporary settings on the client, but that means we have to wait for the user to download all JavaScript, parse it and execute before the request is triggered. This can be slow, especially on slower connections. It can also mean that some elements that rely on these settings can appear after the page has loaded, resulting in a cumulative layout shift
Motivation
More context: https://github.com/sourcegraph/sourcegraph/pull/25692#pullrequestreview-774097800
We currently fetch temporary settings on the client, but that means we have to wait for the user to download all JavaScript, parse it and execute before the request is triggered. This can be slow, especially on slower connections. It can also mean that some elements that rely on these settings can appear after the page has loaded, resulting in a cumulative layout shift
Solution
We should aim to fetch authenticated settings on the server, and return the result as part of the rendered HTML. This is similar to how we implement
jsContext
: https://sourcegraph.com/github.com/sourcegraph/sourcegraph@tr/nps-survey-dismiss-temporary-settings/-/blob/cmd/frontend/internal/app/jscontext/jscontext.go#L41:2If this works successfully, we should consider implementing this strategy with other common queries, like
FeatureFlags
andViewerSettings
cc: @limitedmage