diff --git a/dev/index.html b/dev/index.html index 6cd5871..cbd5bff 100644 --- a/dev/index.html +++ b/dev/index.html @@ -21,4 +21,4 @@ │ └── TestImage.png ├── index.html └── pages - └── blah.html
Calling serve()
from within this directory starts a file server. It serves the contents of the directory as a static site, with the folder structure defining the paths of the URLs. That is, the file blah.html
can be viewed at /pages/blah.html
. When a directory is specified instead of a file, the server checks whether there is a file index.html
in this directory and serves it if available.
Visiting http://localhost:8000/
makes your browser send a standard HTTP GET
request to the server. The server, running a listener loop, receives this request, looks for index.html
in the root folder, and serves it. After serving it, LiveServer
adds this file to the list of watched files. That is, whenever this file changes, a callback is fired (see below). The HTML page may also contain references to style sheets or pictures, which are then requested by your browser as well. The server sends them to the browser, and also adds them to the list of watched files.
Triggering a page refresh in the browser is achieved by a WebSocket connection. The WebSocket API, according to MDN, is
an advanced technology that makes it possible to open a two-way interactive communication session between the user's browser and a server.
LiveServer
injects a small piece of JavaScript code into every HTML file before serving it. This snippet is executed by the browser and opens a WebSocket connection to the server, which in turn adds it to a list of viewers of this page.
The server can now send the message "update" to all viewers of a page whenever the page is changed. The code snippet reacts to this message by triggering a page reload. The update is triggered by the callback mentioned above. When the file is not an HTML file, the viewers of any HTML file are updated, since LiveServer
currently does not keep track of which HTML files reference what other files.
Settings
This document was generated with Documenter.jl version 0.27.25 on Saturday 2 November 2024. Using Julia version 1.9.4.