How use firebase in single JavaScript file & multiple HTML files?

Viewed 17

I am using lot of html files but only one script.js in my website. I am successfully import modules <script type="module">import { initializeApp } from 'https://www.gstatic.com/firebasejs/9.9.4/firebase-app.js'</script> within the html file by following the official documentation. But It's huge work because of I've lot of html files. Also the module type import is not global. So I cant use the variables in the script.js

I do import Firebase modules in script.js like below

import { initializeApp } from 'https://www.gstatic.com/firebasejs/9.9.4/firebase-app.js'

But I got error in firefox,

Uncaught SyntaxError: import declarations may only appear at top level of a module

In chrome browser I can see error

Uncaught SyntaxError: Cannot use import statement outside a module

I just want to import / use firebase into the script.js instead of html module import. Is there any way to do?

Thanking you!

0 Answers
Related