aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Duncan <pabs@pablotron.org>2025-04-01 00:43:21 -0400
committerPaul Duncan <pabs@pablotron.org>2025-04-01 00:43:21 -0400
commitc5ad9e769eeb0d1cfa3d1ecbade6fe1a7fd6f33d (patch)
tree346d2bff7622d9e31da3c63e42caf351d087ae12
parentd7b1c6b124fe8ea9bc159da62ddbf7139c13558f (diff)
downloadpablotron.org-c5ad9e769eeb0d1cfa3d1ecbade6fe1a7fd6f33d.tar.xz
pablotron.org-c5ad9e769eeb0d1cfa3d1ecbade6fe1a7fd6f33d.zip
content/articles/site-backend.md: update script.js excerpt and sizes, add "minified" link
-rw-r--r--content/articles/site-backend.md35
1 files changed, 21 insertions, 14 deletions
diff --git a/content/articles/site-backend.md b/content/articles/site-backend.md
index b235e99..5e752a2 100644
--- a/content/articles/site-backend.md
+++ b/content/articles/site-backend.md
@@ -118,8 +118,9 @@ Here are a few articles which cover guidelines that I follow:
Images are created as follows:
- Mathematical content is created using [Mathy][], saved as [SVG][],
- minified using [minify][], and served cached and compressed by [Apache][].
-- Charts are created with [Matplotlib][], saved as [SVG][], minified
+ [minified][] using [minify][], and served cached and compressed by
+ [Apache][].
+- Charts are created with [Matplotlib][], saved as [SVG][], [minified][]
with [minify][], and served cached and compressed by [Apache][]
Example: [This Python script][bench-chart] was used to generate the
bar charts in [this blog post][post-fips203ipd].
@@ -160,36 +161,40 @@ that is used is minimal, [modern][es2015], [deferred][], and only used
for the [theme switcher][post-theme-switcher] and burger menu.
Below is the unminified `script.js` for this site with some notes
-removed. It is served as 777 bytes minified and 586 bytes minified and
-compressed:
+removed. It is served as 699 bytes [minified][] and 508 bytes
+[minified][] and compressed:
```js
'use strict';
//
-// script.js - script which handles:
+// script.js: minimal JS for pablotron.org
//
-// - set theme
-// - theme switcher and burger menu event handlers
+// - set theme on page load
+// - bind theme switcher and burger menu event handlers
+//
+// current sizes (2025-04-01):
+// - minified: 699 bytes
+// - minified/compressed: 508 bytes
//
+// aliases
const D = document,
C = D.body.parentElement.classList,
L = localStorage,
M = window.matchMedia,
on = (el, id, fn) => el.addEventListener(id, fn);
-// use theme if set, otherwise fall back dark mode
-C.add('dark');
+// light theme selected by user?
if (L && L.theme && L.theme === 'light') {
C.remove('dark'); // set light theme
}
-document.addEventListener('DOMContentLoaded', () => {
+D.addEventListener('DOMContentLoaded', () => {
// theme toggle event handler
- on(D.querySelector('.navbar-item[data-id="theme"]'), 'click', (e) => {
+ on(D.querySelector('.navbar-item[data-id="theme"]'), 'click', e => {
e.preventDefault(); // stop event
- L.theme = C.toggle('dark') ? 'dark' : 'light'; // toggle
+ L.theme = C.toggle('dark') ? 'dark' : 'light'; // toggle theme
});
// iterate through burgers, bind to click events
@@ -461,8 +466,8 @@ table.table
```
[Download][style.sass.txt]
-With these changes the generated [CSS][] is 137 kB minified and 16 kB
-minified and compressed.
+With these changes the generated [CSS][] is 137 kB [minified][] and 16 kB
+[minified][] and compressed.
### Hugo Configuration
@@ -811,3 +816,5 @@ published.
"AI / LLM User-Agents: Blocking Guide"
[llm]: https://en.wikipedia.org/wiki/Large_language_model
"Large Language Model"
+[minified]: https://en.wikipedia.org/wiki/Minification_(programming)
+ "Minification (Wikipedia)"