Location
auth/auth.js:9
Problem
newGetUser() is called at module parse time, before the window.load event fires:
// runs immediately at parse time
newGetUser();
// runs after DOM is fully ready
window.addEventListener('load', () => {
displayAuth();
});
The network call itself is harmless before load, but the pattern is inconsistent with the rest of the file and could cause ordering issues if newGetUser is ever extended to touch the DOM.
Suggested fix
Either move the call inside the load handler, or add a comment explaining the intentional early-call:
window.addEventListener('load', async () => {
// redirect immediately if already signed in
const user = await getUser();
if (user) location.replace('/');
displayAuth();
});
This consolidates startup logic in one place.
Location
auth/auth.js:9Problem
newGetUser()is called at module parse time, before thewindow.loadevent fires:The network call itself is harmless before load, but the pattern is inconsistent with the rest of the file and could cause ordering issues if
newGetUseris ever extended to touch the DOM.Suggested fix
Either move the call inside the
loadhandler, or add a comment explaining the intentional early-call:This consolidates startup logic in one place.