openvibers/openvibe.live Commits
broadcast.css loads with the broadcast desk and the dashboard, not on every page (#683)
Changes
@@@ -235,7 +235,8 @@"broadcast": {"fragment": "broadcast","css": [-- "/css/features/broadcast.css"++ "/css/features/broadcast.css",++ "/css/broadcast.css"],"deps": ["money",@@@ -292,7 +293,8 @@"dashboard": {"fragment": "dashboard","css": [-- "/css/features/dashboard.css"++ "/css/features/dashboard.css",++ "/css/broadcast.css"],"deps": ["money",@@@ -107,7 +107,7 @@<!-- Stylesheets.Blocking set = what the home page paints with. Everything else belongs to another route-- (the broadcast desk, the messenger, the cosmetics modal, after-show reports, the guide++ (the messenger, the cosmetics modal, after-show reports, the guideoverlay) and is fetched without blocking the first paint: media="print" makes the browsertreat it as non-critical, and the onload flips it back to all once it has arrived. --><link rel="stylesheet" href="/css/style.css">@@@ -119,12 +119,10 @@<link rel="stylesheet" href="/css/i18n-star.css"><!-- chat-shared.css belongs to the chat (features.json → chatUI): the pages that have chat askfor it there, and a page without chat does not download it. -->-- <link rel="stylesheet" href="/css/broadcast.css" media="print" onload="this.media='all';this.onload=null"><link rel="stylesheet" href="/css/cosmetics.css" media="print" onload="this.media='all';this.onload=null"><noscript><!-- Without JavaScript the chat never fills, but the pages that have one still show it. --><link rel="stylesheet" href="/css/chat-shared.css">-- <link rel="stylesheet" href="/css/broadcast.css"><link rel="stylesheet" href="/css/cosmetics.css"></noscript>nnew file mode 100644@@@ -0,0 +1,24 @@++'use strict';++/**++ * /css/broadcast.css (the broadcast desk's styles, 11 KB) is not on every page (11-07, the owner: "make things faster++ * and more optimized"): the broadcast desk and the dashboard (its settings rows) bring it through features.json.++ * node test/broadcast-css-on-demand.test.js++ */++const assert = require('assert');++const fs = require('fs');++const path = require('path');++++const pub = (p) => fs.readFileSync(path.join(__dirname, '..', 'public', p), 'utf8');++const html = pub('index.html');++const reg = JSON.parse(pub('features.json')).features;++++assert.ok(!/<link[^>]+href="\/css\/broadcast\.css"/.test(html), 'broadcast.css is not on every page');++assert.ok(reg.broadcast.css.includes('/css/broadcast.css'), 'the broadcast desk brings it');++assert.ok(reg.dashboard.css.includes('/css/broadcast.css'), 'the dashboard brings it (its settings rows)');++// What it styles outside the desk: the dashboard's settings rows, and nothing else in the shared shell.++assert.ok(pub('fragments/dashboard.html').includes('settings-row-content'), 'the dashboard still uses its settings rows');++for (const cls of ['bc-camera-sheet', 'settings-row-content']) {++ assert.ok(!html.includes(cls), `${cls} is not in the shared shell`);++}++++console.log('broadcast css on demand: only the broadcast desk and the dashboard load broadcast.css');
@@ -235,7 +235,8 @@
@@ -235,7 +235,8 @@
"broadcast": {
"broadcast": {
"fragment": "broadcast",
"fragment": "broadcast",
"css": [
"css": [
- "/css/features/broadcast.css"
+ "/css/features/broadcast.css",
+ "/css/broadcast.css"
],
],
"deps": [
"deps": [
"money",
"money",
@@ -292,7 +293,8 @@
@@ -292,7 +293,8 @@
"dashboard": {
"dashboard": {
"fragment": "dashboard",
"fragment": "dashboard",
"css": [
"css": [
- "/css/features/dashboard.css"
+ "/css/features/dashboard.css",
+ "/css/broadcast.css"
],
],
"deps": [
"deps": [
"money",
"money",
@@ -107,7 +107,7 @@
@@ -107,7 +107,7 @@
<!-- Stylesheets.
<!-- Stylesheets.
Blocking set = what the home page paints with. Everything else belongs to another route
Blocking set = what the home page paints with. Everything else belongs to another route
- (the broadcast desk, the messenger, the cosmetics modal, after-show reports, the guide
+ (the messenger, the cosmetics modal, after-show reports, the guide
overlay) and is fetched without blocking the first paint: media="print" makes the browser
overlay) and is fetched without blocking the first paint: media="print" makes the browser
treat it as non-critical, and the onload flips it back to all once it has arrived. -->
treat it as non-critical, and the onload flips it back to all once it has arrived. -->
<link rel="stylesheet" href="/css/style.css">
<link rel="stylesheet" href="/css/style.css">
@@ -119,12 +119,10 @@
@@ -119,12 +119,10 @@
<link rel="stylesheet" href="/css/i18n-star.css">
<link rel="stylesheet" href="/css/i18n-star.css">
<!-- chat-shared.css belongs to the chat (features.json → chatUI): the pages that have chat ask
<!-- chat-shared.css belongs to the chat (features.json → chatUI): the pages that have chat ask
for it there, and a page without chat does not download it. -->
for it there, and a page without chat does not download it. -->
- <link rel="stylesheet" href="/css/broadcast.css" media="print" onload="this.media='all';this.onload=null">
<link rel="stylesheet" href="/css/cosmetics.css" media="print" onload="this.media='all';this.onload=null">
<link rel="stylesheet" href="/css/cosmetics.css" media="print" onload="this.media='all';this.onload=null">
<noscript>
<noscript>
<!-- Without JavaScript the chat never fills, but the pages that have one still show it. -->
<!-- Without JavaScript the chat never fills, but the pages that have one still show it. -->
<link rel="stylesheet" href="/css/chat-shared.css">
<link rel="stylesheet" href="/css/chat-shared.css">
- <link rel="stylesheet" href="/css/broadcast.css">
<link rel="stylesheet" href="/css/cosmetics.css">
<link rel="stylesheet" href="/css/cosmetics.css">
</noscript>
</noscript>
new file mode 100644
new file mode 100644
@@ -0,0 +1,24 @@
@@ -0,0 +1,24 @@
+'use strict';
+/**
+ * /css/broadcast.css (the broadcast desk's styles, 11 KB) is not on every page (11-07, the owner: "make things faster
+ * and more optimized"): the broadcast desk and the dashboard (its settings rows) bring it through features.json.
+ * node test/broadcast-css-on-demand.test.js
+ */
+const assert = require('assert');
+const fs = require('fs');
+const path = require('path');
+
+const pub = (p) => fs.readFileSync(path.join(__dirname, '..', 'public', p), 'utf8');
+const html = pub('index.html');
+const reg = JSON.parse(pub('features.json')).features;
+
+assert.ok(!/<link[^>]+href="\/css\/broadcast\.css"/.test(html), 'broadcast.css is not on every page');
+assert.ok(reg.broadcast.css.includes('/css/broadcast.css'), 'the broadcast desk brings it');
+assert.ok(reg.dashboard.css.includes('/css/broadcast.css'), 'the dashboard brings it (its settings rows)');
+// What it styles outside the desk: the dashboard's settings rows, and nothing else in the shared shell.
+assert.ok(pub('fragments/dashboard.html').includes('settings-row-content'), 'the dashboard still uses its settings rows');
+for (const cls of ['bc-camera-sheet', 'settings-row-content']) {
+ assert.ok(!html.includes(cls), `${cls} is not in the shared shell`);
+}
+
+console.log('broadcast css on demand: only the broadcast desk and the dashboard load broadcast.css');