I wanted to access app in the second script, but I got an undefined error.
<head>
<link rel="stylesheet" href="styles.css">
<script type="module">
import {
initializeApp
} from "https://www.gstatic.com/firebasejs/9.6.1/firebase-app.js";
import {
getFirestore,
collection,
getDocs
} from "https://www.gstatic.com/firebasejs/9.6.1/firebase-firestore.js";
const firebaseConfig = {
apiKey: "**********",
authDomain: "**",
projectId: "*"
};
// Initialize Firebase
const app = initializeApp(firebaseConfig);
const db = getFirestore(app);
console.log(app);
</script>
<script src="app.js" defer></script>
</head>
I am just using a console.log(app)
in the second script tag.
I am also using defer to delay. Below is the output on the console.