Using Visual Studio Code
4. Running your code
The easiest way to run your code it to open up the index.html page that is associated with your project.
In order for this to work, your index page must have the following code, usually in its <head> section:
This code tells the page to load the file main.js in the js folder. The word defer tells it not to load the JavaScript code until after the web page has fully loaded.
If you've used different folder or files names, you'll need to substitute them.
VS Code lets you quickly copy the path to a page, allowing you to paste it into your browser address bar.
- Right click your projects index.html file and choose Copy Path.
- In your web browser, right click in the address bar and choose Paste and Go.
⚠ You do not need to repeat this process every time you change your program code. Just save it in VS Code (Ctrl - S) and then refresh your web browser with the F5 key.