Skip to content

@ogygia/devtools · Dock

Dock

A panel on your page that outlines every region, says what each one cost to load, shows the data the server sent it and times when it woke. Always on in dev, and switched on per browser in a preview build.

On this page

An ogygia page is server HTML with a few islands of JavaScript in it. When something is off, the questions are about those islands: which parts of the page are islands at all, what each one cost to download, what data the server sent it, whether it woke from the server’s markup, and why it woke late. Your browser’s devtools can’t answer them, because they don’t know what a region is.

The dock can. It’s a panel that mounts on the page and reads the events ogygia’s runtime sends as it works, plus the server’s events for the same page. List the plugin, start the dev server, and click og devtools at the bottom right of any page.

Installation covers the setup, and Options lists the plugin’s options.

import { sveltekit } from '@sveltejs/kit/vite';
import { ogygia } from 'ogygia/vite';
import { devtools } from '@ogygia/devtools/vite';
import { defineConfig } from 'vite';

export default defineConfig(({ mode }) => ({
  plugins: [
    ogygia(),
     ...(mode !== 'production'
      ? [devtools()]
      : []) ,
    sveltekit()
  ]
}));

Dev server

On the dev server, the dock is always on. Every page gets a small og devtools button at the bottom right (on a csr = true page the dock shows the Page tab alone, see below). The dock’s own code loads once the page has finished loading and the browser is idle, so its work never lands inside the page load it measures. A click before then loads it at once.

The dev server also tells the dock each island’s component name and an estimate of its code size, which is why the tabs say Counter rather than a hashed file name.

In dev, ogygia.devtools.on() and the other switches below just answer that the dock is always on.

Builds

A build that lists the plugin, such as a QA or preview deploy, shows visitors nothing. Their pages carry no launcher, take no measurements and get none of the server’s events. What they do pay for is small: a launcher module that checks a cookie and stops there, and the runtime’s event stream, which keeps its events in memory and sends nothing anywhere.

To use the dock on that build, turn it on in your own browser:

  • add ?og-devtools=on to any page’s address (1 and true work too; the address drops it once applied), or
  • run ogygia.devtools.on() in the browser console.

Either one sets an og_devtools cookie (path /, SameSite=Lax, 30 days). The server reads it too: a ?og-devtools=on request sets it on that very response. From then on, in that browser only:

  • the launcher shows on every page, and the dock’s code downloads when you open it;
  • pages are measured from the start of each load, for the Page tab, and ogygia.handle() sends them with Document-Policy: js-profiling, so the Page tab can sample the main thread;
  • the server adds its events to each page, for the Wire tab and the island cards, and answers those pages with cache-control: private, no-store so a shared cache never keeps a copy with them in. A page stored by postrender is rendered fresh for you instead.

ogygia.devtools.on() shows the launcher at once; measuring starts with the next load. A prerendered page has no server to read the cookie, so it shows the launcher but carries no server events.

To turn it off, use ?og-devtools=off (or 0, false), ogygia.devtools.off(), or the hide button in the dock’s title bar. The launcher and dock go at once. ogygia.devtools.off() and hide also forget the dock’s saved position; ?og-devtools=off keeps it, so a dock left open comes back open the next time you turn it on (#2304). ogygia.devtools.status() says whether it’s on in this browser.

A few things stay dev-only:

  • A Kit-hydrated (csr = true) page gets no dock in a build.
  • Component names come from the build, but the module-by-module size estimates and the few findings built on them (barrels, one heavy module) need the dev server.
https://preview.example.com/pricing?og-devtools=on
ogygia.devtools.status();
// 'ogygia devtools: off in this browser'
ogygia.devtools.on();
// 'ogygia devtools: on in this browser (stays on; ogygia.devtools.off() to hide it)'

Window

Click the launcher, or press Alt+O, to open the dock; press Alt+O again or ✕ to close it. Once the dock’s code is in (on the dev server, shortly after the page loads; in a build, once you open it on that page, or at once when you left it open), the launcher peeks up from the bottom edge and shows itself fully when you hover it. You can then drag it out of the way, and it rests above any fixed bar at the bottom of your page (a phone-style tab bar), so it never covers your own buttons. Until then, in a build, it’s a plain button pinned at the bottom right that brightens on hover.

The dock opens near the launcher at 600 × 680 px. Drag it by its title bar and resize it from any edge or corner, down to 300 × 200. It can sit partly off-screen without giving your page a scrollbar. Its position, size and whether it’s open are saved in localStorage (ogygia:devtools:layout:v4), so a reload brings it back as you left it. While it’s open, the visible tab refreshes about every 0.7 seconds.

The title bar has two more buttons:

  • trace copies every event the dock has buffered to the clipboard, as JSON (the trace format). Where the browser refuses the clipboard, such as plain http on a phone on your network, it downloads ogygia-trace-<time>.json instead.
  • hide, in a build only, turns the devtools off in this browser.

The dock lives in a shadow root on <html>, above everything else on the page. Your page’s CSS can’t reach in, its own CSS can’t leak out, and a router swap of <body> never removes it. A page whose Content-Security-Policy refuses inline styles still gets a styled dock.

A dock left open when a page loads draws its own text during that load, and the browser may count that text as the page’s first paint. The Page tab says so when it happens (dock-in-paint). Close the dock and reload for clean numbers, then open it again: it reads the same visit.

Keyboard shortcuts

KeysWhat they do
Alt+OOpen or close the dock. Before the dock’s code is in, it loads the code and opens.
EscCancel pick on page in the Lens tab.
Tab, Shift+TabMove through the tabs, buttons and rows. Each row’s name is a button.
Enter, SpacePress the focused tab or button. On a row’s name, open the row, as a click does.
Arrow keys, Page Up/DownScroll the focused panel. The panel under the tabs takes focus, so you can scroll it without a mouse.

The tabs are a real tab list, so a screen reader announces them as tabs with the open one selected. Text in the dock meets 4.5:1 contrast.

On a Mac, Option+O types ø, and the dock checks for the letter o, so the shortcut doesn’t open it there with most keyboard layouts. Click the launcher instead. This is a known bug (#2304).

Tabs

TabAnswersMore
LensWhere is each region on the page, and what kind is it?Lens
PageWhat did the browser measure on this load, and what went wrong?Page load
RecordWhat does using the page do: clicks, requests, errors, server time?Session recording
HydrationDid each island wake from the server’s markup? If not, what differed?Hydration
BytesHow much JavaScript does each island cost, alone and shared?Bytes
WireWhat data did the server send each island, and the page?Wire
HubWhich shared objects do several islands hold?Hub
NavWhat did the last in-app navigation keep, patch, mount and remove?Nav
TimelineWhen did each island connect, wake and finish hydrating?Timeline
ProfilerWhere did this page’s server render spend its time?Profiler tab

Clicking a region in the Lens, Page or Profiler tab, or a Hydration row with no difference, opens its island card, which pulls every tab’s numbers for that one region together.

localhost:5173/shop
ogygia devtools a mock of seven of the dock's ten tabs; the numbers are made up
3 islands · 1 lake · 1 hole · 11.0 KB JS · 1 cold

Region kinds

The dock reads each <ogygia-region> on the page and sorts it by the two settings the compiler writes on it. Each kind shows different things:

RegionShown asIts wake columnIts stateJS cost
Client islandislandload, idle, visible, interaction, or the media querycold until it wakes, then hydratedits code and imports
An island inside an awake islandislandits own setting, never usedcold (with its parent), then rides its parentas above
Server islandholeholepending until its HTML arrives, then filled0 B
Lakelakelakepending0 B

A nested island never wakes on its own: it hydrates as part of the island around it, so the dock reports it with that island: asleep while its parent is, awake with it, never on its own. A lake is plain server HTML with no life in the browser, but the Lens still lists it as pending, and that never changes. Read it as “nothing to wait for”; it’s a known bug (#2304). A live region reads filled once its first answer is on the page.

Only islands have a hydration status, a byte row and a lifecycle. Every region the server rendered appears in the Wire tab with its mode. Holes also get their own waterfall in the Page tab, with how long each one showed its fallback, and the Wire tab lists the signed capability each one was given.

Kit-hydrated pages

On a csr = true page, SvelteKit hydrates the whole page and ogygia’s runtime never starts, so there are no islands, no wire and no byte ledger. On the dev server the dock still opens there. Its title bar says csr=true, it explains why the island tabs are missing, and it shows the Page tab alone, with the vitals, the files, other origins and styles. A build gives such a page no dock.

Error handling

The dock never breaks your page. When something goes wrong, it says so in the browser console with a message code:

CodeWhen
devtools_dock_load_failedThe dock’s code didn’t download (a network error, or a deploy removed the file). The launcher goes back to og devtools, and the next click or Alt+O asks again under a fresh URL. Also said when a recording can’t resume on the next page.
devtools_page_beacon_load_failedIn a build with the devtools on, in an app without ogygia.handle(): the script that measures the page didn’t load or start, so this page isn’t measured. The next load tries again. Said once per page.
devtools_on_in_buildPrinted by vite build once, whenever the dock is listed in a build.

The dock never mounts on the profiler’s own pages (/__profiler and below), so it never inspects itself.

Overhead

The devtools measure the page they show, so they’re built not to change it. Turning the devtools on adds the server’s events to the HTML and a small recorder to the page. A check in the repo loads a heavy test page (17,000 elements, 30 islands) with the devtools on and off in turn, and fails if they add more than 60 ms of main-thread time or 4 KB of HTML. With the dock closed, nothing of it runs in a loop; with it open, each tab does a few milliseconds of work per refresh and never causes a long task.