From 01e52bad1651ceb2b44604cd4cc814a9880bce69 Mon Sep 17 00:00:00 2001
From: Rohan Kumar
Date: Tue, 19 Apr 2022 18:06:57 -0700
Subject: [PATCH] Split up figcaption partial, add some fignos
- give code blocks their own figure numbers/names/ID
- Split figcaption into quotecaption and codecaption
- create codefigure partial to reduce markup for SoftwareSourceCode
figures
---
content/posts/website-best-practices.md | 146 ++++++++++--------------
layouts/posts/single.html | 1 +
layouts/shortcodes/codecaption.html | 6 +
layouts/shortcodes/codefigure.html | 10 ++
layouts/shortcodes/figcaption.html | 22 ----
layouts/shortcodes/quotecaption.html | 8 ++
6 files changed, 88 insertions(+), 105 deletions(-)
create mode 100644 layouts/shortcodes/codecaption.html
create mode 100644 layouts/shortcodes/codefigure.html
delete mode 100644 layouts/shortcodes/figcaption.html
create mode 100644 layouts/shortcodes/quotecaption.html
diff --git a/content/posts/website-best-practices.md b/content/posts/website-best-practices.md
index b8737b6..1ccf273 100644
--- a/content/posts/website-best-practices.md
+++ b/content/posts/website-best-practices.md
@@ -67,12 +67,9 @@ Consider taking hardening measures to maximize the security benefits made possib
JavaScript and WebAssembly are responsible for the bulk of modern web exploits. If that isn't reason enough, most [non-mainstream search indexes](./../../../2021/03/10/search-engines-with-own-indexes.html) have little to no support for JavaScript. Ideally, a text-oriented site can enforce a scripting ban at the [Content Security Policy](https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP) (CSP) level.
-
+{{}}
`default-src: 'none'` implies `script-src: 'none'`, causing a compliant browser to forbid the loading of scripts. Furthermore, the `sandbox` CSP directive forbids a [wide variety of risky actions](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/sandbox). While `script-src` restricts script loading, `sandbox` can also restrict script execution with stronger defenses against script injection (e.g. by a browser add-on).[^1] I added the `allow-same-origin` parameter so that these add-ons will still be able to function.[^2]
@@ -102,10 +99,10 @@ If you're able to control your HTTP headers, then use headers instead of a ` that's enforced late.
-{{< figcaption type="citation" partOfType="TechArticle" >}}
+{{< quotecaption partOfType="TechArticle" >}}
HTML Living Standard, section 4.2.5.3: Pragma directives,
Content Security Policy state
-{{< /figcaption >}}
+{{< /quotecaption >}}
### If you must enable scripts
@@ -141,16 +138,13 @@ Optimal loading is a complex topic. Broadly, it covers three overlapping categor
HTML is a blocking resource: images and stylesheets will not load until the user agent loads and parses the HTML that calls them. To start loading above-the-fold images before the HTML parsing finishes, send a `link` HTTP header.
-
+{{}}
### Don't count on the cache
@@ -162,16 +156,13 @@ Requesting a high number of cached resources can decrease performance of the cac
One way to help browsers decide which disk-cached resources to prioritize is to use immutable assets. Include the `immutable` directive in your `cache-control` headers, and cache-bust modified assets by changing their URLs.
-
+{{}}
You can also keep your asset counts low by combining textual assets (e.g. CSS) and inlining small resources.
@@ -199,10 +190,10 @@ There is only one honest measure of web performance: **the time from when you cl
Everything else is bullshit.
-{{< figcaption type="citation" partOfType="TechArticle" >}}
+{{< quotecaption partOfType="TechArticle" >}}
{{}},
{{}}
-{{< /figcaption >}}
+{{< /quotecaption >}}
Plenty of other factors exist, but listing them all is beyond the scope of this article.
@@ -282,11 +273,11 @@ Lazy loading may or may not work. Some browsers, including Firefox and the Tor B
Loading is only deferred when JavaScript is enabled. This is an anti-tracking measure, because if a user agent supported lazy loading when scripting is disabled, it would still be possible for a site to track a user's approximate scroll position throughout a session, by strategically placing images in a page's markup such that a server can track how many images are requested and when.
- {{< figcaption type="citation" partof="TechArticle">}}
+ {{< quotecaption partOfType="TechArticle">}}
{{}}
on MDN,
the loading attribute
- {{< /figcaption >}}
+ {{< /quotecaption >}}
If you can't rely on lazy loading, your pages should work well without it. If pages work well without lazy loading, is it worth enabling?
@@ -355,10 +346,10 @@ Long pages with many DOM nodes may benefit from CSS containment, a more recently
`content-visibility: auto` is a more complex value than `hidden`; rather than being similar to `display: none`, it adaptively hides/displays an element's contents as they become relevant to the user. It also doesn’t hide its skipped contents from the user agent, so screen readers, in-page search, and other tools can still interact with it.
-{{< figcaption type="citation" partOfType="TechArticle" >}}
+{{< quotecaption partOfType="TechArticle" >}}
CSS Containment Module Level 2, section 4.2:
Using content-visibility: auto
-{{< /figcaption >}}
+{{< /quotecaption >}}
Leveraging containment is a progressive enhancement, so there aren't any serious implications for older browsers. I use it for my site footers and endnotes.
@@ -436,16 +427,13 @@ Browsers allow users to zoom by adjusting size metrics. Additionally, most brows
In your stylesheets, avoid using `px` where possible. Define sizes and dimensions using relative units (preferably `em`). Exceptions exist for some decorations[^9] (e.g. borders), but they are uncommon.
-
+{{}}
Beyond alt-text
---------------
@@ -477,10 +465,10 @@ Blind users might struggle to view images in context; they can't easily scan the
Try reading your screen through a drinking straw for an hour to get an idea of the limited context that a blind user has. You simply cannot scan the entire page at a glance with a screenreader - you have to listen to the structure of it carefully and remember all that, or read through the entire thing to find stuff, unless there are explicit associations such as longdesc.
-{{< figcaption type="citation" partOfType="EmailMessage" >}}
+{{< quotecaption partOfType="EmailMessage" >}}
{{}},
{{}}
-{{< /figcaption >}}
+{{< /quotecaption >}}
Being sighted and loading images can introduce issues of its own. Sometimes, sighted readers might focus on the _wrong_ part of an image. How can you give readers the missing context and tell them what to focus on?
@@ -526,10 +514,10 @@ I personally try to maintain the flow of an article even if its figures and capt
using such relative references, so that the page can easily be restyled without affecting the
page's meaning.
-{{< figcaption type="citation" partOfType="TechArticle" >}}
+{{< quotecaption partOfType="TechArticle" >}}
HTML Living Standard, section 4.4.12:
The figure element
-{{< /figcaption >}}
+{{< /quotecaption >}}
### Image transcripts {#image-transcripts}
@@ -640,10 +628,10 @@ Underlines also make it easy for color-blind readers to distinguish both the beg
Color is not used as the only visual means of conveying information, indicating an action, prompting a response, or distinguishing a visual element. (Level A)
-{{< figcaption type="citation" partOfType="TechArticle" >}}
+{{< quotecaption partOfType="TechArticle" >}}
{{< cited-work name="WCAG 2.2" extraName="headline" url="https://www.w3.org/TR/WCAG22/" >}},
section 1.4.1
-{{< /figcaption >}}
+{{< /quotecaption >}}
Readers already expect underlined text to signify a hyperlink. Don't break fundamental affordances for aesthetics.
@@ -683,12 +671,11 @@ Most of my images will probably be screenshots that start as PNGs. My typical fl
6. Create a lossy AVIF image from the cropped full-color PNG, and include it in the `