<script> WebPDF loader

Works in all major browsers
Since July 2026

WebPDF works in Chrome and Edge 125, Firefox 153 and Safari 18, on desktop and mobile, and in every later version: the oldest versions its PDF.js build supports, which already have every platform feature WebPDF needs. Since July 2026, that is every major browser.

The <script> element that loads WebPDF, <script src=//new.webpdf.pro/.js type=module>, also takes attributes: defaults for every <pdf-file> and <pdf-page> in the document, and switches for built-in behaviors. Everything else about it is the <script> element you know.

Try it

<script src=//new.webpdf.pro/.js type=module controls toolbar=top></script>

<pdf-file id=f src=//pdf.ist/web.pdf></pdf-file>
<pdf-page of=f scale=0.5></pdf-page>

The above example gives every page of the document viewer controls with the bar at the top, from the <script> alone.

Attributes

WebPDF finds its own <script> by its src: a URL with webpdf in it, or .js on the same origin. A copy you host elsewhere needs a webpdf attribute.

src

//new.webpdf.pro/.js: WebPDF, served from its CDN.

type

module. Required.

-

Tokens every page leaves out: text, anno, drop, controls, js. Multi-homed.

break

Space-separated tokens that turn built-in behaviors off; see below. Read once, when WebPDF loads.

controls

A Boolean attribute: every page gets viewer controls. Multi-homed.

controlslist

Controls every page leaves out: parts of the bar, the bar (notoolbar) or the gestures (nogestures). Multi-homed.

debug

A Boolean attribute: traces events, phases and fetches to the console.

event:prefix

type renames every event to pdf-file-load, pdf-page-render and so on. Multi-homed.

fonts

A Boolean attribute: keeps font data, so SVG exports embed their fonts.

ium

PDFium for every file. A bare ium only makes it available: pages draw with PDF.js until one asks for PDFium, with canvas=ium, the I key or the bar's menu, and PDFium loads then. ium=+ also makes it every file's default, as ium on a file does. Read once. Multi-homed.

measure

A Boolean attribute: writes performance marks and measures for every page phase, such as 🌐📄/p:r/.js.a-z.1.

placeholder:aspect-ratio

The box of every page while its PDF is on the way: a paper name, a ratio or -. Multi-homed.

quiet

A Boolean attribute: keeps the console quiet: no banner, no error logs.

signatures

A Boolean attribute: every page shows its signature cards. Multi-homed.

toolbar

The edge of every page's bar. Multi-homed.

trust:src

Trust anchors for every file, from one URL. They add up with each file's own. Multi-homed.

trust:srcdoc

Trust anchors for every file, inline. Multi-homed.

trust:stores

Root stores every file trusts: aatl, eutl, ms, moz. Multi-homed.

workers

How many SVG pages the background worker builds at once: 1 to 8; the default is 2.

Breaking built-in behaviors

break takes space-separated tokens, such as break="lazy hint":

TokenTurns off
svg-workerthe background worker: <pdf-page svg> is built on the main thread
verifysignature verification: no checks, hotspots, cards or verify events
revocationonline revocation checks (OCSP, CRL, AIA); revocation data in the PDF is still used
content-visibilitythe built-in content-visibility: auto of pages
lazyloading=lazy: every page draws at once
hintremembered page sizes and the regional paper that reserve boxes before a PDF loads (an explicit placeholder:aspect-ratio still does)
prefetchidle prefetch of the neighboring pages of a page with controls
fullscreenF, F11, the bar's ⛶ and toggleFullscreen()
aspect-ratiothe aspect-ratio of pages (--aspect-ratio stays set)
imagethe image layer (text and annotations still render)
cleanupreleasing PDF.js page resources after SVG builds
hwaPDF.js hardware-accelerated canvases
FSAthe File System Access API (also 💾): pickers fall back to <input type=file> and downloads

Usage notes

Examples

Controls on every page, except one

html
<script src=//new.webpdf.pro/.js type=module controls></script>
<pdf-file id=f src=//pdf.ist/web.pdf></pdf-file>
<pdf-page of=f></pdf-page>
<pdf-page of=f no=2 controls=-></pdf-page>

Every page at once, without placeholders

html
<script src=//new.webpdf.pro/.js type=module quiet break="lazy hint"></script>

Technical summary

DOM interfaceHTMLScriptElement
Element<script>

Specifications

Not part of any specification. <pdf-file> and <pdf-page> are autonomous custom elements defined by WebPDF.pro.

Browser compatibility

desktopmobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
script
1251251531111812515383182712518
break
1251251531111812515383182712518
controls
1251251531111812515383182712518
debug
1251251531111812515383182712518
event:prefix
1251251531111812515383182712518
fonts
1251251531111812515383182712518
ium
1251251531111812515383182712518
measure
1251251531111812515383182712518
quiet
1251251531111812515383182712518
signatures
1251251531111812515383182712518
workers
1251251531111812515383182712518

Legend

Full support

See also