Skip to content

Blank Boxes in an Offline Manual: Vendoring Mermaid, Adding Zoom

Adityo Guni Waluyo

Manual diagrams opened via file:// came up blank because mermaid loaded from a CDN. The fix: vendor mermaid 11 locally plus a 50-300 percent zoom toolbar.

TL;DR

The manual's diagrams silently failed offline because Mermaid loaded from a CDN. The fix bundles Mermaid 11 locally, consolidates configuration into one site-level initialize call, and rewrites all nine diagrams as plain-text pre.mermaid blocks with a theme observer for re-rendering. A zoom toolbar (50–300 percent) with pan support makes wide diagrams readable, while PDF export keeps vector art.

I opened the manual page straight from the download folder, calling it through a file:// address in the browser, and the nine boxes that were supposed to show the system architecture appeared empty. No error message. No spinner. Just white space across the page, exactly where the diagrams should have been.

The first theory was wrong. I suspected the diagram sources were broken, maybe a label with a strange character that the parser rejected. Each file was checked one by one; all valid. What actually happened was far more boring: the browser was offline, the Mermaid script loaded from a CDN, and the browser stayed silent when the request failed. No fallback, no helpful console note.

The manual built by the portal generator was designed to be read without a network. In fact, the most important diagrams inside it were the only assets still depending on the internet.

Ending the CDN dependency

The decision was blunt: the Mermaid version 11 bundle was copied into a local vendor folder inside the documentation package, and every manual page loads it through a path relative to the HTML file. Opening the manual over the local file protocol, from a local static server, or from an archive extracted onto a flash drive now looks exactly the same.

Configuration was consolidated too. Before, theme settings and diagram parameters were repeated on every page. Now they live in a single site-level initialize call, because that is how Mermaid configuration works: that call applies overrides to all diagrams on the page [1].

You can verify this yourself. Load the manual page from the local file protocol, open the Network panel in DevTools, and reload. Not a single request to an external domain should appear. If one does, one file has not been moved yet.

The result is measurable. Total downloads per manual page visit drop because the diagrams no longer pull a script from the network, and more importantly, losing the connection no longer changes the content of the page.

Rewriting nine diagrams

Since the diagrams had to be touched anyway, all of them were standardized at once. Each image block became a client-rendered pre.mermaid block, so the diagram source still reads as plain text for readers who disable JavaScript.

One data-relation diagram uses the ER syntax with primary key and foreign key markers on each attribute, plus one-to-many cardinality on both sides of every relation. The rest are flowcharts mapping the cluster, runtime, module, request-flow, infrastructure, and release views. The graph keyword still appears in a few older diagrams because it is simply an alias of flowchart in Mermaid syntax [4].

Two things need configuring in one place. First, the site configuration that applies overrides to every diagram. Second, a data-theme attribute observer that triggers re-rendering when a reader switches between the light and dark themes.

// Konfigurasi situs: initialize menerapkan override ke seluruh diagram
mermaid.initialize({ startOnLoad: false, theme: document.documentElement.dataset.theme });

// Observer data-theme: render ulang diagram saat pembaca berpindah tema
new MutationObserver(renderAllDiagrams).observe(
  document.documentElement,
  { attributes: true, attributeFilter: ["data-theme"] }
);

Without that re-render, a diagram already rendered in the light theme stays light on a page that has just gone dark. A theme switch has to regenerate the image, not just swap the page background.

Zoom, not just full scale

The next problem appeared once the diagrams rendered. The cluster architecture diagram is wide, and at the manual page container width the result is attribute text a few pixels tall. Fit-width turns out to be not a solution for wide diagrams but a new way to make them unreadable.

So every diagram got a small toolbar with minus, plus, and Fit buttons. The initial value fits the container width, and the zoom range is 50 to 300 percent. The mechanism uses transform on the diagram element, the CSS property built for scaling, rotating, or shifting an element [2].

When the zoom passes the container width, the wrapper area around the diagram needs to be pannable. That is where overflow comes in: content that passes the box edges becomes scrollable overflow, and the overflow properties provide a scrolling mechanism to contain it [3]. The combination keeps the diagram visually full-size while the reader pans right to read the not-yet-visible part.

The official PDF path was left alone. The PDF export route keeps the original vector art, no transform, no toolbar, no resolution change.

My position is firm: documentation that calls itself offline must be tested while offline, with all of its supporting assets. Copying one JavaScript file into the repository sounds like a trivial household chore, yet in this case it decided whether the manual could be read at all. A diagram that depends on a CDN is not an offline diagram, just one that happens to be online often.

Sources

[1] Mermaid, Configuration page, accessed 2026-11-09.

[2] MDN, the transform property, accessed 2026-11-09.

[3] MDN, the CSS overflow module, accessed 2026-11-09.

[4] Mermaid, Flowchart syntax, accessed 2026-11-09.

Related articles