Improve page load time by better sequencing things.

This commit is contained in:
mtail 2019-02-27 07:41:41 -08:00
parent 90ca7be213
commit 8f3a92c419
4 changed files with 22 additions and 20 deletions

View File

@ -1,5 +1,5 @@
const click="click",mouseenter="mouseenter",mouseleave="mouseleave",active="active";
"use strict";const escapeChars={"¢":"cent","£":"pound","¥":"yen","€":"euro","©":"copy","®":"reg","<":"lt",">":"gt",'"':"quot","&":"amp","'":"#39"},regex=/[¢£¥€©®<>"&']/g;function escapeHTML(a){return a.replace(regex,function(a){return"&"+escapeChars[a]+";"})}function saveFile(a,b){const c=document.createElement("a");c.setAttribute("href","data:text/text;charset=utf-8,"+encodeURI(b)),c.setAttribute("download",a),c.click()}function printText(a){const b=window.open("","","left=0,top=0,width=100,height=100,toolbar=0,scrollbars=0,status=0,location=0,menubar=0",!1);b.document.write("<html><body><pre><code>"+a+"</code></pre></html>"),b.document.close(),b.focus(),b.print(),b.close()}function navigateToUrlOrRoot(a){const b=new XMLHttpRequest;b.open("GET",a,!0),b.onreadystatechange=()=>{if(4===b.readyState&&404===b.status){const b=new URL(a);b.pathname="",a=b.toString()}window.location.href=a},b.send()}function onDOMLoaded(a){listen(document,"DOMContentLoaded",a)}function getById(a){return document.getElementById(a)}function query(a,b){return a.querySelector(b)}function queryAll(a,b){return a.querySelectorAll(b)}function listen(a,b,c){a.addEventListener(b,c)}
"use strict";const darkThemeClass="dark-theme",darkTheme="Dark Theme",darkThemeItem="dark-theme-item",lightTheme="Light Theme",lightThemeItem="light-theme-item",styleCookie="style";function applyStyleSheet(a){a===darkTheme?document.body.classList.add(darkThemeClass):document.body.classList.remove(darkThemeClass);let b=getById(lightThemeItem);b&&(a===lightTheme?b.classList.add(active):b.classList.remove(active)),b=getById(darkThemeItem),b&&(a===darkTheme?b.classList.add(active):b.classList.remove(active))}function createCookie(a,b,c){let d="";if(c){const a=new Date;a.setTime(a.getTime()+1e3*(60*(60*(24*c)))),d="; expires="+a.toGMTString()}document.cookie=a+"="+b+d+"; path=/"}function readCookie(a){const b=a+"=",d=document.cookie.split(";");for(let e,c=0;c<d.length;c++){for(e=d[c];" "===e.charAt(0);)e=e.substring(1,e.length);if(0===e.indexOf(b)){let a=e.substring(b.length,e.length);return"light"===a?a=lightTheme:"dark"===a&&(a=darkTheme),a}}return null}function loadActiveStyleSheet(){let a=readCookie(styleCookie);null!==a&&applyStyleSheet(a)}loadActiveStyleSheet(),onDOMLoaded(()=>{function a(a){applyStyleSheet(a),createCookie(styleCookie,a)}loadActiveStyleSheet(),listen(getById(lightThemeItem),click,()=>(a(lightTheme),!1)),listen(getById(darkThemeItem),click,()=>(a(darkTheme),!1))});
"use strict";const darkThemeClass="dark-theme",darkTheme="Dark Theme",darkThemeItem="dark-theme-item",lightTheme="Light Theme",lightThemeItem="light-theme-item",styleCookie="style";function applyStyleSheet(a){a===darkTheme?document.body.classList.add(darkThemeClass):document.body.classList.remove(darkThemeClass);let b=getById(lightThemeItem);b&&(a===darkTheme?b.classList.remove(active):b.classList.add(active)),b=getById(darkThemeItem),b&&(a===darkTheme?b.classList.add(active):b.classList.remove(active))}function createCookie(a,b,c){let d="";if(c){const a=new Date;a.setTime(a.getTime()+1e3*(60*(60*(24*c)))),d="; expires="+a.toGMTString()}document.cookie=a+"="+b+d+"; path=/"}function readCookie(a){const b=a+"=",d=document.cookie.split(";");for(let e,c=0;c<d.length;c++){for(e=d[c];" "===e.charAt(0);)e=e.substring(1,e.length);if(0===e.indexOf(b)){let a=e.substring(b.length,e.length);return"light"===a?a=lightTheme:"dark"===a&&(a=darkTheme),a}}return null}let cookieValue=readCookie(styleCookie);applyStyleSheet(cookieValue),onDOMLoaded(()=>{applyStyleSheet(cookieValue),listen(getById(lightThemeItem),click,()=>(applyStyleSheet(lightTheme),createCookie(styleCookie,lightTheme),!1)),listen(getById(darkThemeItem),click,()=>(applyStyleSheet(darkTheme),createCookie(styleCookie,darkTheme),!1))});
//# sourceMappingURL=styleSwitcher.min.js.map

File diff suppressed because one or more lines are too long

View File

@ -80,15 +80,6 @@
</script>
<!-- End Google Analytics -->
<script>
const branchName = "{{ .Site.Data.args.source_branch_name }}";
const docTitle = "{{ .Title }}";
const iconFile = "{{ .Site.BaseURL}}/img/icons.svg";
const buttonCopy = '{{ i18n "button_copy" }}';
const buttonPrint = '{{ i18n "button_print" }}';
const buttonDownload = '{{ i18n "button_download" }}';
</script>
<!-- RSS -->
<link rel="alternate" type="application/rss+xml" title="Istio Blog" href="/feed.xml">
@ -110,7 +101,7 @@
<meta name="application-name" content="Istio">
<!-- style sheets -->
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Work+Sans:400,500,300,700,300italic,400italic,500italic,700italic|Chivo:400,500,300,700,300italic,400italic,500italic,700italic">
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Work+Sans:400|Chivo:400|Work+Sans:500,300,700,300italic,400italic,500italic,700italic|Chivo:500,300,700,300italic,400italic,500italic,700italic">
<link rel="stylesheet" href="/css/all.css">
</head>
@ -122,8 +113,26 @@
{{ end }}
<body class="language-unknown {{ $site_mode}}">
<!-- set the color theme as soon as possible -->
<script src="/js/styleSwitcher.min.js"></script>
<!-- inject some build-time constants into JavaScript-land -->
<script>
const branchName = "{{ .Site.Data.args.source_branch_name }}";
const docTitle = "{{ .Title }}";
const iconFile = "{{ .Site.BaseURL}}/img/icons.svg";
const buttonCopy = '{{ i18n "button_copy" }}';
const buttonPrint = '{{ i18n "button_print" }}';
const buttonDownload = '{{ i18n "button_download" }}';
</script>
<!-- libraries we pull in -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" defer></script>
<script src="https://www.google.com/cse/brand?form=search-form" defer></script>
<!-- our own stuff -->
<script src="/js/all.min.js" data-manual defer></script>
{{ partial "header.html" . }}
{{ block "main" . }}{{ end }}
{{ partial "footer.html" . }}
@ -158,12 +167,5 @@
</a>
</div>
{{ end }}
<!-- libraries we pull in -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js"></script>
<script src="https://www.google.com/cse/brand?form=search-form"></script>
<!-- our own scripts -->
<script src="/js/all.min.js" data-manual></script>
</body>
</html>

View File

@ -1 +1 @@
"use strict"; const darkThemeClass = 'dark-theme'; const darkTheme = 'Dark Theme'; const darkThemeItem = 'dark-theme-item'; const lightTheme = 'Light Theme'; const lightThemeItem = 'light-theme-item'; const styleCookie = 'style'; function applyStyleSheet(title) { if (title === darkTheme) { document.body.classList.add(darkThemeClass); } else { document.body.classList.remove(darkThemeClass); } // set the active theme menu item let item = getById(lightThemeItem); if (item) { if (title === lightTheme) { item.classList.add(active); } else { item.classList.remove(active); } } item = getById(darkThemeItem); if (item) { if (title === darkTheme) { item.classList.add(active); } else { item.classList.remove(active); } } } function createCookie(name, value, days) { let expires = ""; if (days) { const date = new Date(); date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000)); expires = "; expires=" + date.toGMTString(); } document.cookie = name + "=" + value + expires + "; path=/"; } function readCookie(name) { const nameEQ = name + "="; const ca = document.cookie.split(';'); for (let i = 0; i < ca.length; i++) { let c = ca[i]; while (c.charAt(0) === ' ') { c = c.substring(1, c.length); } if (c.indexOf(nameEQ) === 0) { let result = c.substring(nameEQ.length, c.length); // convert legacy cookie values if (result === "light") { result = lightTheme; } else if (result === "dark") { result = darkTheme; } return result; } } return null; } function loadActiveStyleSheet() { let cookie = readCookie(styleCookie); if (cookie !== null) { applyStyleSheet(cookie); } } loadActiveStyleSheet(); onDOMLoaded(() => { loadActiveStyleSheet(); function loadActiveStyleSheet() { function loadActiveStyleSheet() { function loadActiveStyleSheet() { let cookie = readCookie(styleCookie); function loadActiveStyleSheet() { if (cookie !== null) { } function loadActiveStyleSheet() { applyStyleSheet(cookie); function loadActiveStyleSheet() { } function loadActiveStyleSheet() { } }); listen(getById(darkThemeItem), click, () => { setActiveStyleSheet(darkTheme); return false; }); });
"use strict"; const darkThemeClass = 'dark-theme'; const darkTheme = 'Dark Theme'; const darkThemeItem = 'dark-theme-item'; const lightTheme = 'Light Theme'; const lightThemeItem = 'light-theme-item'; const styleCookie = 'style'; function applyStyleSheet(title) { if (title === darkTheme) { document.body.classList.add(darkThemeClass); } else { document.body.classList.remove(darkThemeClass); } // set the active theme menu item let item = getById(lightThemeItem); if (item) { if (title === darkTheme) { item.classList.remove(active); } else { item.classList.add(active); } } item = getById(darkThemeItem); if (item) { if (title === darkTheme) { item.classList.add(active); } else { item.classList.remove(active); } } } function createCookie(name, value, days) { let expires = ""; if (days) { const date = new Date(); date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000)); expires = "; expires=" + date.toGMTString(); } document.cookie = name + "=" + value + expires + "; path=/"; } function readCookie(name) { const nameEQ = name + "="; const ca = document.cookie.split(';'); for (let i = 0; i < ca.length; i++) { let c = ca[i]; while (c.charAt(0) === ' ') { c = c.substring(1, c.length); } if (c.indexOf(nameEQ) === 0) { let result = c.substring(nameEQ.length, c.length); // convert legacy cookie values if (result === "light") { result = lightTheme; } else if (result === "dark") { result = darkTheme; } return result; } } return null; } let cookie = readCookie(styleCookie); applyStyleSheet(cookieValue); onDOMLoaded(() => { applyStyleSheet(cookieValue); function loadActiveStyleSheet() { applyStyleSheet(cookie); let cookie = readCookie(styleCookie); if (cookie !== null) { let cookie = readCookie(styleCookie); applyStyleSheet(cookie); function loadActiveStyleSheet() { } }); listen(getById(darkThemeItem), click, () => { applyStyleSheet(darkTheme); createCookie(styleCookie, darkTheme); return false; }); });