Link previews from the browser, with no server and no third party

'My link preview tool has no server. The providers answer the browser.' above a curl check of CORS headers: YouTube, Vimeo and WordPress oEmbed allow the origin, and Reddit sends no header.

Embed preview, the tool in my lab, shows the link preview Telegram, Slack and X would roughly draw for a page, from its oEmbed, Open Graph and X Card tags. It runs in the browser with no server of its own, and no third-party service reads the page for it.

The short version: seven big providers’ oEmbed endpoints and WordPress’s own oEmbed route answer a browser directly. For any other page, a bookmarklet reads the tags where the page is already open, and pasting the page’s HTML works with no network at all. The price is that typing an ordinary article’s URL no longer gives a card. Whatever reads the tags, the cards are still guesses, because only X documents which tags it reads and how it falls back.

I built it on November 26, 2026, with Microlink reading every page the providers didn’t cover, and swapped Microlink for the bookmarklet the next day. The tool is on its lab page. This post is mostly my own notes on both decisions, so I remember why there’s no fetcher, why there’s no Microlink, and what the tool can’t tell me.

Why I dropped the fetcher before writing it

The backlog note for this tool said to plan safe server-side URL fetching first, with private-network blocking and response limits. That’s the usual answer: a browser page can’t read another site’s HTML, so something else fetches it.

The first proposal put a small fetcher on Cloudflare Workers, on the lab hostname. It had the guards you’d expect for a URL fetcher: refuse private, loopback, link-local and cloud metadata addresses, check again on every redirect, stop after three redirects, five seconds per hop, cap the response size, forward no cookies.

One guard couldn’t be done cheaply. A Worker’s fetch() takes a hostname and does its own DNS lookup after mine, so a hostile DNS server could hand back a private address the second time. Cloudflare’s raw TCP sockets refuse private addresses and localhost,1 but using them meant writing an HTTP client by hand. It also needed a new Cloudflare token with Workers access, and a deploy step for code that lives apart from the tool.

I said no. A server piece is one more thing to deploy, patch and watch, and a small lab tool isn’t worth that. So the question became whether the tool could work from the browser alone, and what it would lose.

What a browser page can actually read

A page can read a response from another site only when that site sends an access-control-allow-origin header. Ordinary web pages don’t, mine included, so the page itself is out. That left two kinds of source.

Provider oEmbed endpoints answer browsers

oEmbed is a small JSON format a site offers for its own links, found through a <link rel="alternate" type="application/json+oembed"> tag in the page head.2 The spec says nothing about CORS, so whether a browser can call an endpoint is up to each provider. On November 26, 2026, fetch() calls from a test page in headless Chrome, and curl with an Origin header, gave these:

curl -s -o /dev/null -D - -H 'Origin: https://lab.ivankristianto.com' \
  'https://vimeo.com/api/oembed.json?url=https://vimeo.com/76979871' | grep -i '^access-control-allow-origin'
youtube.com/oembed             yes
vimeo.com/api/oembed.json      yes
publish.twitter.com/oembed     yes (redirects to publish.x.com, also yes)
soundcloud.com/oembed          yes
open.spotify.com/oembed        yes
tiktok.com/oembed              yes
embed.bsky.app/oembed          yes
<wordpress site>/wp-json/oembed/1.0/embed   yes
flickr.com/services/oembed     no
reddit.com/oembed              no

So a YouTube, Vimeo, X, SoundCloud, Spotify, TikTok or Bluesky link goes straight to that provider’s endpoint from the visitor’s browser. Any other address gets one try at WordPress’s route on the same host.3 Between them they cover the big embeds and posts on WordPress sites installed at the root, but not an ordinary article page, and oEmbed gives the card’s title and thumbnail, not the page’s own tags.

Reader services read the rest, for a price

For any other page, on November 26, that meant a third-party service reading it. Jina’s reader returned the og:* and twitter:* tags (one value per tag name) plus the link rels, at 20 requests a minute per IP with no key, though for a YouTube page it found no og:* tags at all. Microlink’s free endpoint answered too, at five a day.

noembed.com only knows its listed providers, so a plain page got “no matching providers”. allorigins.win was down that day, and corsproxy.io now wants an API key. Pasting the page’s HTML into the tool needs none of them.

The first version sent every page the providers didn’t cover to Microlink. It shipped on November 26 and came out on November 27.

Picking it over the reader with more tags

Jina’s reader was the better fit on paper: more tags, a higher limit. Its terms decided it. Section 4.5 forbids using “automated methods to extract information, data or result from the JINA-AI website or the Services, including by means of scraping, harvesting, or web data extraction.”4 A tool that sends every visitor’s URL to it is exactly that, so I picked Microlink.

Microlink normally returns its own merged fields: one title, one description, one image.5 The tool needed the raw tags, so it could show which tag each card field came from. It turned Microlink’s own extraction off with meta=false and asked for each head tag with a data rule, a CSS selector plus the attribute to read:5,6,7

const params = new URLSearchParams({ url: pageUrl, meta: 'false' });
TAGS.forEach((tag, i) => {
  params.set(`data.t${i}.selector`, tag.selector);
  params.set(`data.t${i}.attr`, tag.attr);
});

TAGS has 19 entries: <title>, the meta description, nine og:* tags, five twitter:* tags, and the icon, canonical and oEmbed links.8 The same list is what the bookmarklet reads now.

Five lookups a day, and other people’s URLs on someone else’s server

Microlink’s docs give the free plan five requests without a key and 25 with one.9 Five is small, and it runs out. Later on November 26 the limit was already used up for my IP:

curl -sS -D - -H 'Origin: https://lab.ivankristianto.com' -G https://api.microlink.io/ \
  --data-urlencode 'url=https://www.ivankristianto.com/lab/font-split-inspector/' \
  --data-urlencode 'meta=false' \
  --data-urlencode 'data.ogtitle.selector=meta[property="og:title"]' \
  --data-urlencode 'data.ogtitle.attr=content'
HTTP/2 429
access-control-allow-origin: *
x-rate-limit-limit: 5
x-rate-limit-remaining: 0
{"status":"fail","code":"ERATE","more":"https://microlink.io/erate","message":"Your daily rate limit has been reached. Upgrade to a PRO plan."}

The first version read that ERATE code and opened the paste section, so the tool kept working. The other cost stayed: every address that wasn’t a provider link went to Microlink’s servers. On November 27 I took Microlink out.10 I wanted fewer third parties and a simpler tool that runs fully client side.

A bookmarklet reads the page instead

A page in my lab can’t read another site, but a bookmarklet runs on that site, in the tab the visitor already has open. It replaces Microlink for every page the oEmbed endpoints don’t cover.

The tags travel after the #

You drag the tool’s “Embed preview” link to the bookmarks bar and click it on the page you want to check. It reads the 19 tags with document.querySelector, then opens the tool in a new tab with the values in the URL fragment:3

function collect(tool, tags) {
  const data = new URLSearchParams({ url: location.href });
  for (const [name, selector, attr] of tags) {
    const node = document.querySelector(selector);
    const value = node && (attr === 'text' ? node.textContent : node.getAttribute(attr));
    if (value && value.trim()) data.append(name, value.trim().slice(0, 2000));
  }
  open(`${tool}#${data}`, '_blank', 'noopener,noreferrer');
}

A browser doesn’t send the part after # with a request, so the tags never reach a server, mine included. noreferrer keeps the page’s address out of the request for the tool.11 On November 27 the bookmarklet on a wordpress.org/news post read 15 tags and drew all three cards, with no request to microlink.io. The URL path misses that post, because WordPress there lives under /news/ and the tool only tries the route at the host’s root, which answered 404.

The fragment gets the same rules as pasted HTML

Anyone can build a link with a fragment, so the tool reads it as untrusted text. It keeps only the tag names it knows and the first value of each, keeps a URL only if it’s http or https, cuts values to the same lengths as pasted HTML, and refuses a fragment over 50,000 characters. Nothing in it is evaluated. A declared oEmbed link is listed, never fetched.3,11

Pasted HTML is read as text with regular expressions, never parsed into a DOM. Page text reaches the page through textContent only, oEmbed html is shown as text and never rendered, and requests send no cookies and no referrer.11 This head has a javascript: image and a second og:title hidden inside a script:

<head><title>Demo</title>
<meta property="og:title" content="A demo page">
<meta property="og:image" content="javascript:alert(1)">
<script>x = '<meta property="og:title" content="from a script">'</script>
<meta name="twitter:card" content="summary_large_image"></head>

The tool reads og:title as “A demo page”, not the copy inside the script, and drops the javascript: image:

title        found     og:title
description  missing   -
image        missing   -
site name    missing   -
x card       found     twitter:card
x title      fallback  og:title

The tool can say which tags a page has and which one each card would use. It can’t say what each app will draw, because the apps document very different amounts.

X documents its fallbacks

X’s card markup page lists twitter:title, twitter:description and twitter:image, each falling back to og:title, og:description and og:image. It caps the title at 70 characters and the description at 200, wants images under 5 MB, and doesn’t support SVG. Without twitter:card, a page with og:type, og:title and og:description “may” get a summary card.12 That’s from a February 2026 copy of the page, because the old docs URL now redirects to the new docs home.

Slack and Telegram say much less

Slack’s docs say its classic unfurl “looks for common OpenGraph and X (formerly known as Twitter) Card metadata”, with no order between them.13 Telegram documents the fields of a preview (site name, title, description, photo) but not which tags fill them.14 The tool reads og:* first for both and falls back to <title> and the meta description. That order is my choice, not theirs.8

None of the cards shows what an app’s own crawler got. The bookmarklet reads the page as the visitor’s browser has it, and a site can serve its bots different HTML. Preview images load straight from their hosts with no referrer, so the image host still sees the visitor’s IP.11

What the embed preview still can’t do

I haven’t compared any card with a real share in Telegram, Slack or X, which is why the page calls them approximations. These stay as known gaps:

  • Typing an ordinary page’s URL gives no card. Only the providers and WordPress answer a browser, so the tool points to the bookmarklet or paste.3
  • A site whose Content Security Policy blocks bookmarklets needs paste.11 The November 27 checks skipped page CSP, so they didn’t meet one.10
  • WordPress installed in a subfolder misses the oEmbed try. The bookmarklet covers it.11
  • Dragging the bookmarklet out of the lab entry’s embedded frame wasn’t tested.10
  • Private and localhost addresses are refused before any request. The bookmarklet or paste covers them.3

If you want to check how your own page shares:

  • Run the bookmarklet on it, or paste its <head> into the tool when the site blocks bookmarklets. The tags stay in your browser either way.
  • Set twitter:card if X matters to you. Without it, the best X may give you is a small summary card, and only when og:type, og:title and og:description are all there.
  • If you’re building a link preview tool, check each provider’s oEmbed endpoint for the CORS header before you reach for a proxy. Seven of the nine I listed send it.

The code is in the ik2-lab repo. The first version merged on November 26,15 and the version without Microlink merged on November 27 as v0.0.7, with 25 tests passing in CI.10

Sources