Clean Code

Web - Browsersync


Browsersync is a web server to support automatic reloading for easy web development. Very simple and easy to use.

Installation of browsersync on Ubuntu

Install Node.js

Refer to my article to install node.js on ubuntu


Chrome browser should be installed.


Let’s use npm to install browsersync as below:

npm install -g browser-sync

How to use browsersync

Sample code

  1. Make a project folder
  2. make a html file as the following.


<!doctype html>
  <meta charset="utf-8">
  <h1> BrowserSync </h1>

Run browsersync

In the project folder, type the following command.

browser-sync start --server --directory --files "*"

Do the following command so that you can synchronize the change of the internal files.

browser-sync start --server --directory --files "**/*"

If you can see that a new page is launched on a new chrome tab, it would succeed. Select the example file.

Test browsersync

Modify the html file and save it. The page on the chrome tab must be refreshed automatically.

  <h1> BrowserSync update! </h1>