The second environment option you might want to install on your computer is also simple, but it requires installing a web server. If an HTML file contains only simple JavaScript code that does not require any request to a server (Ajax calls), it can be executed in the browser by right-clicking on the HTML file and selecting the Open with option. The code we will develop throughout this book is simple and it can be executed using this approach. However, it is always nice to have a web server installed.
There are many open source and free options available to you. If you are familiar with PHP, XAMPP (https://www.apachefriends.org) is a good option, and it is available for Linux, Windows, and Mac OS.
Since we will be focusing on JavaScript for the server side and the browser, there is also a simpler web server you can install in Chrome. It is the Web Server for Chrome extension, and this can be downloaded at https://goo.gl/pxqLmU. After installing it, you can access it through the Chrome URL chrome://apps:
After opening the Web Server extension, you can CHOOSE FOLDER you want to serve in the browser. You can create a new folder in which you can execute the source code we will implement throughout this book, or you can download the source code from this book and extract it to a directory of your preference and access it through the informed URL (the default is http://127.0.0.1:8887):
All examples from this book can be executed by accessing http://127.0.0.1:8887/examples. You will find an index.html with a list of all examples, as demonstrated in the following screenshot:
When executing the examples, always remember to have the Developer Tools enabled and the Console tab open to see the output. The Web Server for Chrome extension was also developed using JavaScript. For better experience, it is recommended to use this extension to execute the examples from this book or install the Node.js http-server we will learn in the next section.