Configure optional text view in EdgePress
Most recent changes
Added
Each site keeps command entries under its own tools/ and regression cases under tests/. This site provides npm run test:data-saver and npm run verify:performance. The benchmark uses a cold cache, gzip, 100 KB/s and 150 ms latency, reporting first contentful paint separately from readable content. Shared implementations come from the pinned EdgePress dependency. Theme developers can follow the public tool guide with their own paths and locales, without access to this site's source. Anonymous local fixtures do not verify live services or publishing accounts.
Text view is useful when the full page takes too long to load or when a reader wants to save data. It is optional, and a theme must provide a readable lightweight variant before the site enables it. The default view stays full; the reader chooses whether to switch.
Enable it in site configuration
Merge this into the existing site object in config.yml rather than adding a second site key:
site:
dataSaver:
enabled: true
debug: false
mode: auto
detectSlowConnection: true
respectBrowserPreference: false
promptAfterMs: 5000
| Setting | What it does |
|---|---|
enabled |
Enables the optional loading and text-view flow. Default: false. |
mode: auto |
Starts with full view unless the reader has made an explicit choice. |
detectSlowConnection |
Offers text view while the first screen waits for resources. It does not switch automatically from a network speed label. |
promptAfterMs |
Sets the delayed offer threshold; 5000 means five seconds. Valid range: 100–60000. |
respectBrowserPreference: false |
Keeps the initial choice independent of browser data-saving hints. |
debug: false |
Keeps the empty ?data-save preview entry disabled on the public site. |
A saved reader choice takes precedence over the site's automatic starting mode. mode: text or mode: full changes the configured starting preference; neither is needed for the flow above.
Let the theme define the lightweight presentation
Merge dataSaver into the active theme's theme.json:
{
"name": "my-theme",
"renderer": "layouts/layout.html",
"templateEngine": "edgepress-partials-v1",
"dataSaver": {
"stylesheet": "data-saver-theme.css",
"scripts": [],
"layoutStyles": ["style.css"]
}
}
The stylesheet and scripts are paths relative to the theme's assets/ directory. layoutStyles lists shared published CSS; the build compiles it with font-face rules and URL declarations removed. This helps retain real navigation, rows, cards and footer geometry without downloading decorative assets. The variant stylesheet supplies its own typography and colors. Keep titles, article excerpts, timestamps, captions and visible focus usable.
Text view uses system fonts and defers pictures, project clips, document engines and optional service widgets. Readers can request individual media or return to full view. Charts and screenshots still need useful descriptions; saving data should not remove the explanation that makes an article understandable.
Keep service choice separate from media loading
Accepting consent does not download every optional widget. A service request still needs current per-service consent and a reason to load that widget. For a remote document, the source must also permit CORS. Keep the flat service list and each service's disclosures; there are no category switches to enable whole groups.
For dynamic theme media, call window.edgepressDataSaver?.deferMedia(element, activate, description) before assigning a URL. Make activate assign the URL only when requested, and provide a fallback when data-saving support is disabled. Mark nonessential full-view scripts with data-data-optional. Hiding an image after setting src is too late to save its request.
Test the waiting screen and navigation
Throttle actual resource transfers to about 100 KB/s, open a fresh page, and switch to text view while full styles and media are still pending. Check that the waiting screen's controls are keyboard accessible, progress reflects completed resources, late resources do not replace the chosen view, and article navigation preserves the choice. Inspect request logs for fonts, pictures, clips and widgets; hidden pixels are not proof that a request was avoided.
Also test the return to full view, mobile footer boundaries and a page without JavaScript. debug: true permits the empty ?data-save test entry; when it is disabled, that entry goes to the localized static 404 page. This client navigation does not prove an HTTP 404 from the host. Keep debug false after testing.
Each site keeps command entries under its own tools/ and regression cases under tests/. This site provides npm run test:data-saver and npm run verify:performance. The benchmark uses a cold cache, gzip, 100 KB/s and 150 ms latency, reporting first contentful paint separately from readable content. Shared implementations come from the pinned EdgePress dependency. Theme developers can follow the public tool guide with their own paths and locales, without access to this site's source. Anonymous local fixtures do not verify live services or publishing accounts.