firebase.initializeApp callback/promise?
<p>This is my web page</p>

<pre><code>&lt;!DOCTYPE html&gt;
&lt;html&gt;
    &lt;head&gt;
        &lt;meta charset="utf-8"&gt;
        &lt;meta http-equiv="X-UA-Compatible" content="IE=edge"&gt;
        &lt;meta name="viewport" content="width=device-width, initial-scale=1"&gt;
        &lt;title&gt;Calcolo Diliuzioni&lt;/title&gt;

    &lt;/head&gt;
    &lt;body&gt;

        &lt;h1&gt;My app&lt;/h1&gt;

        &lt;!-- Libreria per gestire l'autenticazione con google --&gt;
        &lt;script src="https://apis.google.com/js/platform.js" async defer&gt;&lt;/script&gt;

        &lt;!-- Firebae config --&gt;
        &lt;script src="https://www.gstatic.com/firebasejs/live/3.0/firebase.js"&gt;&lt;/script&gt;
        &lt;script&gt;
        // Initialize Firebase
        var config = {
        apiKey: "",
        authDomain: "",
        databaseURL: "",
        storageBucket: "",
        };
        firebase.initializeApp(config);
        &lt;/script&gt;

        &lt;script type="text/javascript"&gt;
            var user = firebase.auth().currentUser;
            if (user) {
                console.log(user);
            } else {
                console.log(user);
            }
        &lt;/script&gt;
    &lt;/body&gt;
&lt;/html&gt;
</code></pre>

<p>Let's assume I have an already logged user. When I load the page in the console I got <code>null</code>. While I'm expecting to have the current user's object.</p>

<p>If I run the same code in the browser console</p>

<pre><code>var user = firebase.auth().currentUser;
if (user) {
    console.log(user);
} else {
    console.log(user);
}
</code></pre>

<p>I'm able to get the current user's object. </p>

<p>I think that the <code>firebase.initializeApp(config);</code> has some async behavior. What's the right way to work around it? Should I use a promise or something on the <code>firebase.initializeApp(config);</code> function? A sort of callback..</p>