title: Firebase 9.4.1 and Javscript Authentication function "onAuthStateChanged" works slowly
body: <p>I am learning Firebase and I am using the latest version 9.4.1 for Web with Javascript and Jquery. I have the following code where I check if the user is currently logged in and if yes then he is not allowed to access the login page. Similarly, if the user is logged in then I also hide the &quot;Sign Up&quot; and &quot;Sign In&quot; buttons and display the &quot;Sign Out&quot; button. However, during my experiment I found out that these actions are performed quite slowly. This means that if I try to access the login page then the page loads for nearly half a second, displays all the contents of the page (login form and stuffs) in a flash for half a second and then decides to redirect back to the index page. Even the &quot;Sign Up&quot; and &quot;Sign In&quot; buttons are displayed for the similar amount of time before getting hidden and &quot;Sign Out&quot; button takes time to display too. Why these delays are there? Is there any way I can eliminate these delays and make the actions be performed instantly?</p>
  <p>Authentication checking code</p>
  <pre><code>onAuthStateChanged(auth, (user) =&gt; {
    if(user){
      const uid = user.uid;
      (window.location.pathname.split(&quot;/&quot;).pop() == 'login.php')?location.replace(&quot;index.php&quot;):null;
      $(&quot;.logout&quot;).show();
      $(&quot;.login&quot;).hide();
      $(&quot;.register&quot;).hide();
    }
  });
  </code></pre>