How to install Edgemesh® Client on Custom Sites
Service Worker
For most custom websites, the installation process can be done manually and typically takes around 5 minutes. Follow the steps below to set up the Edgemesh® Service Worker.
-
Create a file named
sw.js
at the root of your web server. The file should be accessible athttps://yoursite.com/sw.js
. The filename is crucial as the Edgemesh client expects it to be named as such. -
In your
sw.js
file, import the Edgemesh® Service Worker using the following code:
Alternatively, you can download a copy of the sw.js
file here.
Client Script
Next, you will need to add the Edgemesh® Client script to the <head>
element of your website. Ensure that the client code is present on every page of your site. Most sites use a template engine or similar, so you only need to add the script to your header template. However, if your site consists of individual static pages, you must add this script to each HTML file.
Use the following code to add the minimal client script:
If you need to enable specific features beyond the basic installation, you can pass any of the Client Configuration Options to the EDGEMESH
global variable. This allows you to customize the client behavior. To do so, add the configuration script above the client script as shown below:
Feel free to explore the available configuration options in the Client Configuration Options documentation for more advanced customization.
By following these steps and including the necessary files in your website, you will have successfully installed the Edgemesh® Client and Service Worker, enabling enhanced performance and optimization for your site.