Setting up Environment: VSCode, Live Server
Setting up Environment: VSCode, Live Server
To write JavaScript productively, professional developers configure a modern development environment. While you can write code in Notepad, using industry-standard tools like Visual Studio Code (VS Code) and the Live Server extension accelerates your learning and debugging tenfold.
1. Installing Visual Studio Code
Visual Studio Code (VS Code) is the world's most popular free code editor, built by Microsoft using web technologies (Electron, TypeScript, and Node.js).
Step-by-Step Installation:
- 1Navigate to code.visualstudio.com.
- 2Download the installer for your operating system (Windows, macOS, or Linux).
- 3Run the installer. On Windows, ensure you check:
- Add "Open with Code" action to Windows Explorer file context menu.
- Add to PATH.
- 1Launch VS Code.
2. Essential Extensions for JavaScript Developers
In VS Code, click the Extensions icon in the left sidebar (or press Ctrl + Shift + X on Windows / Cmd + Shift + X on Mac). Install the following extensions:
Visual Architecture & Process Flow
How data and code flow step-by-step
3. Creating Your First Project with Live Server
Let's set up a clean, structured project folder:
Step 1: Create Project Folder
On your desktop or projects directory, create a folder named js-starter:
Step 2: Write the HTML Boilerplate (index.html)
In VS Code, open index.html and type ! followed by Tab to generate HTML5 boilerplate:
Step 3: Write Your JavaScript Code (app.js)
Step 4: Launch Live Server
- 1Right-click inside
index.html. - 2Select Open with Live Server (or click "Go Live" in the bottom-right status bar).
- 3A browser window automatically opens at
http://127.0.0.1:5500/index.html. - 4Click the button and watch the text update instantly!
- 5Change any text in VS Code and press
Ctrl + S: the browser reloads automatically without manual refresh!
4. Configuring Prettier "Format on Save"
To ensure your code always looks clean and professionally formatted:
- 1Open VS Code Settings (
Ctrl + ,). - 2Search for Format On Save.
- 3Check the checkbox: Editor: Format On Save.
- 4Set Editor: Default Formatter to Prettier - Code Formatter.
Practice Quiz
http://127.0.0.1:5500 (HTTP protocol) better than double-clicking index.html (file:// protocol)?Variables: var, let, const
Continue learning with hands-on practice, examples, and exercises in the upcoming topic.
Related Lessons
| Previous Lesson | Next Lesson |
|---|---|
| How JavaScript Works in Browser | Variables: var, let, const |
Practice Quiz
Test your understanding of this lesson with 5 questions. Each question has one correct answer.