Can I run JavaScript in the browser without HTML? Why/Why Not?

I’m new to web development and I’m wondering if it’s possible to run a JavaScript file in the browser without using HTML and a <script> tag, and without using a framework.

I’m only asking because in React (using create-react-app), the index.js file just runs in the browser without any HTML file loading it in. How is this possible?

Any links/articles/insight would be greatly appreciated.

>Solution :

No, it isn’t possible — excluding the REPL terminal in the browser dev tools.

create-react-app does use HTML. The create-react-app server dynamically injects the script tag into the HTML thats in your project in public/index.html. You can see this if you use the browser dev tools to inspect the DOM.

Leave a Reply