To use a MQTT/WS and JS library, you need to do the following.
1) You need a server that supports MQTT/WS.
(I used the browserify option and it worked pretty easily)
This creates a browserMqtt.js which you import.
Then you can use code like this in your JS <script> section:
<script src="./browserMqtt.js"></script>
<script>
client.subscribe("/d/#");
client.on("message", function(topic, payload) {
message = JSON.parse(payload);
if ('shortpress' in message) {
document.getElementById('short').value=Date() ;
} else if ('longpress' in message) {
document.getElementById('long').value=Date() ;
}
});
</script>
Note my example is using secure WebSockets on port 8443, so yours will probably be different.
Paul