openvibers/openvibe.live Commits
Live: notification-ui.js only when someone needs it (29 KB off signed-out views) (#681)
Changes
@@@ -506,7 +506,8 @@<!-- ── OpenVibe shared libs (notifications, account sync, themes) ── --><script src="/shared/theme-loader.js" defer></script><script defer src="/js/ov-display-menu.js"></script>--<script src="/shared/notification-ui.js" defer></script>++<!-- notification-ui.js is not on every page (11-07: 29 KB a signed-out visitor never used): the navbar loads it, by its++ content hash, when it mounts a signed-in person's bell, and the live-alerts offer loads it when asked. --><!-- The requested route's scripts (public/features.json), added by the server after the core ones.Other routes load theirs on navigation through js/ov-loader.js. --><!--ov:route-js-->@@@ -3773,7 +3773,9 @@ async function toggleChannelFollow(username) {*/const LIVE_ALERTS_DECLINED_KEY = 'ov_live_alerts_declined_at';async function offerLiveAlerts(name) {-- const n = window.OpenVibeNotifications;++ let n = window.OpenVibeNotifications;++ // Not on every page any more (index.html): load it the moment it is wanted, if the bar has not yet.++ if (!n && window.ov && typeof ov.loadScript === 'function') { try { await ov.loadScript('/shared/notification-ui.js'); } catch { /* */ } n = window.OpenVibeNotifications; }const box = document.getElementById('toast-container');if (!box || !n || typeof n.pushStatus !== 'function' || typeof n.enablePush !== 'function') return;if (document.getElementById('live-alerts-offer')) return;
@@ -506,7 +506,8 @@
@@ -506,7 +506,8 @@
<!-- ── OpenVibe shared libs (notifications, account sync, themes) ── -->
<!-- ── OpenVibe shared libs (notifications, account sync, themes) ── -->
<script src="/shared/theme-loader.js" defer></script>
<script src="/shared/theme-loader.js" defer></script>
<script defer src="/js/ov-display-menu.js"></script>
<script defer src="/js/ov-display-menu.js"></script>
-<script src="/shared/notification-ui.js" defer></script>
+<!-- notification-ui.js is not on every page (11-07: 29 KB a signed-out visitor never used): the navbar loads it, by its
+ content hash, when it mounts a signed-in person's bell, and the live-alerts offer loads it when asked. -->
<!-- The requested route's scripts (public/features.json), added by the server after the core ones.
<!-- The requested route's scripts (public/features.json), added by the server after the core ones.
Other routes load theirs on navigation through js/ov-loader.js. -->
Other routes load theirs on navigation through js/ov-loader.js. -->
<!--ov:route-js-->
<!--ov:route-js-->
@@ -3773,7 +3773,9 @@ async function toggleChannelFollow(username) {
@@ -3773,7 +3773,9 @@ async function toggleChannelFollow(username) {
*/
*/
const LIVE_ALERTS_DECLINED_KEY = 'ov_live_alerts_declined_at';
const LIVE_ALERTS_DECLINED_KEY = 'ov_live_alerts_declined_at';
async function offerLiveAlerts(name) {
async function offerLiveAlerts(name) {
- const n = window.OpenVibeNotifications;
+ let n = window.OpenVibeNotifications;
+ // Not on every page any more (index.html): load it the moment it is wanted, if the bar has not yet.
+ if (!n && window.ov && typeof ov.loadScript === 'function') { try { await ov.loadScript('/shared/notification-ui.js'); } catch { /* */ } n = window.OpenVibeNotifications; }
const box = document.getElementById('toast-container');
const box = document.getElementById('toast-container');
if (!box || !n || typeof n.pushStatus !== 'function' || typeof n.enablePush !== 'function') return;
if (!box || !n || typeof n.pushStatus !== 'function' || typeof n.enablePush !== 'function') return;
if (document.getElementById('live-alerts-offer')) return;
if (document.getElementById('live-alerts-offer')) return;