]> git.sesse.net Git - remoteglot/commitdiff
Send the first JSON inline.
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Wed, 12 Jul 2023 10:18:22 +0000 (12:18 +0200)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Wed, 12 Jul 2023 10:18:22 +0000 (12:18 +0200)
This removes a round-trip, although it's probably slightly less bandwidth-efficient
and definitely more complex. You'll need to make Varnish rewrite / to /index-inline.html
and send it to the backend. It doesn't work on the .dev version, unfortunately.

www/analysis.pl [changed mode: 0755->0644]
www/index.dev.html
www/js/remoteglot.js

old mode 100755 (executable)
new mode 100644 (file)
index a8c02a7c15e8ec7ebb8d6ca5682c75bda8422f52..4562b48d67c76f146e3133e6f214855fb8319c63 100644 (file)
@@ -11,7 +11,7 @@
   <!-- replace <link rel="shortcut icon" href="data:image/png;base64,[base64;favicon.ico]" type="image/png"> -->
   <!-- end replace -->
 
-  <!-- replace <script>[js/remoteglot.min.js]</script> -->
+  <!-- replace <script>/*REPLACE:inlinejson*/[js/remoteglot.min.js]</script> -->
   <script type="text/javascript" src="js/chessboard-0.3.0.js"></script>
   <script type="text/javascript" src="js/chess.js"></script>
   <script type="text/javascript" src="js/json_delta.js"></script>
index ae522e26113c9869d61ef81d47bce9d4f046c4d7..e14fffa2b81394d6c63645182414e7ca1a142119 100644 (file)
@@ -2482,6 +2482,11 @@ function init() {
        document.getElementById("board").addEventListener('mousedown', mousedownSquare);
        document.getElementById("board").addEventListener('mouseup', mouseupSquare);
 
+       if (window['inline_json']) {
+               let j = window['inline_json'];
+               process_update_response(j['data'], { 'get': (h) => j['headers'][h] });
+               delete window['inline_json'];
+       }
        request_update();
        window.addEventListener('resize', function() {
                board.resize();