Cannot use timesync.js in the browser
When I tried to add timesync.js
as a JS script to my .html file, the following warnings appear in the browser console and it doesn't work.
Uncaught SyntaxError: Cannot use import statement outside a module at timesync.js: 9
Uncaught ReferenceError: timesync is not defined at client.html:21
client.html
is as follows. Note that unnecessary code is omitted for brevity.
<!DOCTYPE html>
<html>
<head>
<script src="https://cdnjs.cloudflare.com/ajax/libs/es5-shim/4.0.5/es5-shim.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/es6-shim/0.23.0/es6-shim.min.js"></script>
<script src="./timesync.js"></script>
</head>
<body>
<script>
// create a timesync instance
var ts = timesync.create({
server: "http://localhost:8080/timesync",
interval: 1000
});
var socket = io("http://localhost:8080");
</script>
</body>
</html>