<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Salman Raja</title>
    <description>The latest articles on DEV Community by Salman Raja (@salman_raja).</description>
    <link>https://dev.to/salman_raja</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4223720%2F1e78272d-145f-4b94-819a-452c9f73c408.png</url>
      <title>DEV Community: Salman Raja</title>
      <link>https://dev.to/salman_raja</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/salman_raja"/>
    <language>en</language>
    <item>
      <title>How I Built a ~5KB Zero-Cookie Ad Server on Cloudflare Workers with HMAC-SHA256 Replay Protection</title>
      <dc:creator>Salman Raja</dc:creator>
      <pubDate>Sat, 21 Nov 2026 15:20:55 +0000</pubDate>
      <link>https://dev.to/salman_raja/how-i-built-a-5kb-zero-cookie-ad-server-on-cloudflare-workers-with-hmac-sha256-replay-protection-2i9d</link>
      <guid>https://dev.to/salman_raja/how-i-built-a-5kb-zero-cookie-ad-server-on-cloudflare-workers-with-hmac-sha256-replay-protection-2i9d</guid>
      <description>&lt;p&gt;Most ad scripts on developer blogs are over 150KB, drop third-party tracking cookies, clash with dark mode themes, and slow down page loads.&lt;/p&gt;

&lt;p&gt;Over the past few weeks, I built &lt;strong&gt;AsynchAds(&lt;a href="https://asynchads.com" rel="noopener noreferrer"&gt;https://asynchads.com&lt;/a&gt;)&lt;/strong&gt; — a lightweight, privacy-first white-label ad server running on &lt;strong&gt;Cloudflare Workers + D1&lt;/strong&gt; designed for dev blogs and technical publications that sell their own direct sponsorships.&lt;/p&gt;

&lt;p&gt;Here is how the architecture works under the hood.&lt;/p&gt;




&lt;h3&gt;
  
  
  1. Sub-Millisecond Edge Delivery with Non-Blocking Analytics (&lt;code&gt;ctx.waitUntil&lt;/code&gt;)
&lt;/h3&gt;

&lt;p&gt;When a page requests an ad from &lt;code&gt;/v1/cdn/render&lt;/code&gt;, the hot path needs to return JSON immediately without waiting on database writes.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Single-step D1 lookup:&lt;/strong&gt; Checks the tenant's active direct sponsor flights first, falling back to either collapsing the slot cleanly (&lt;code&gt;display: none&lt;/code&gt;) or rendering the publisher's custom house ad if no sponsor is scheduled.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Off-path telemetry:&lt;/strong&gt; Placement analytics and quota counters run inside &lt;code&gt;ctx.waitUntil(...)&lt;/code&gt;, keeping response latency at a few milliseconds on the Cloudflare edge.&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  2. Stopping Replay &amp;amp; Bot Spam Without Cookies (&lt;code&gt;nonce&lt;/code&gt; + &lt;code&gt;ts&lt;/code&gt; + &lt;code&gt;HMAC-SHA256&lt;/code&gt;)
&lt;/h3&gt;

&lt;p&gt;One of the easiest ways to break an ad server is spamming &lt;code&gt;/click&lt;/code&gt; or &lt;code&gt;/view&lt;/code&gt; endpoints with &lt;code&gt;curl&lt;/code&gt; to inflate sponsor metrics or drain a publisher's monthly impression quota.&lt;/p&gt;

&lt;p&gt;Instead of storing user cookies or fingerprinting visitors, every &lt;code&gt;/v1/cdn/render&lt;/code&gt; response mints short-lived cryptographic tokens for its view and click beacons:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;ts&lt;/code&gt; (Timestamp):&lt;/strong&gt; Rejects expired or future-skewed beacons outside a tight time window.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;nonce&lt;/code&gt;:&lt;/strong&gt; One-time token checked at the edge so replaying the exact same signed beacon URL twice is ignored.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;HMAC-SHA256&lt;/code&gt; Signature:&lt;/strong&gt; Verifies via Web Crypto (&lt;code&gt;crypto.subtle&lt;/code&gt;) that the payload actually originated from our edge Worker.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Edge Bot Filtering:&lt;/strong&gt; Inspects &lt;code&gt;User-Agent&lt;/code&gt; and Cloudflare metadata (&lt;code&gt;request.cf&lt;/code&gt;) plus minimum human view-to-click timing so automated crawlers and headless scrapers don't pollute sponsor reports.&lt;/li&gt;
&lt;/ol&gt;




&lt;h3&gt;
  
  
  3. ~5KB Client Script That Auto-Adapts to Dark/Light Themes
&lt;/h3&gt;

&lt;p&gt;Publishers hate writing custom CSS overrides just to make a sponsor card look native.&lt;/p&gt;

&lt;p&gt;Our client script is Open source on (&lt;a href="https://github.com/AsynchAds/client-script" rel="noopener noreferrer"&gt;https://github.com/AsynchAds/client-script&lt;/a&gt;) stays around &lt;strong&gt;~5KB&lt;/strong&gt; with zero external dependencies:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;XSS-Safe DOM:&lt;/strong&gt; Uses strictly &lt;code&gt;document.createElement&lt;/code&gt; and &lt;code&gt;textContent&lt;/code&gt; (zero &lt;code&gt;innerHTML&lt;/code&gt;) and enforces &lt;code&gt;https://&lt;/code&gt; destination protocols.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Automatic Theme &amp;amp; Typography Detection:&lt;/strong&gt; Reads the host container's computed background color and font family (&lt;code&gt;getComputedStyle&lt;/code&gt;) so &lt;code&gt;card&lt;/code&gt; and &lt;code&gt;inline&lt;/code&gt; placements blend directly into light or dark developer themes out of the box.&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  Try It or Poke Holes in the Architecture
&lt;/h3&gt;

&lt;p&gt;I opened up a &lt;strong&gt;free Sandbox tier (25,000 monthly views, $0, no credit card)&lt;/strong&gt; on &lt;strong&gt;https://://asynchads.com/ad-server&lt;/strong&gt; so anyone running a dev blog or documentation site can test it live.&lt;/p&gt;

&lt;p&gt;If you spot any edge cases in the client script or have ideas to tighten the edge telemetry pipeline further, drop a comment below—happy to share more details on the D1 schema or Worker setup!&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>showdev</category>
      <category>security</category>
      <category>startup</category>
    </item>
    <item>
      <title>Why I’m Building a Privacy-First, Asynchronous Ad Network for Developers</title>
      <dc:creator>Salman Raja</dc:creator>
      <pubDate>Thu, 05 Nov 2026 21:18:19 +0000</pubDate>
      <link>https://dev.to/salman_raja/why-im-building-a-privacy-first-asynchronous-ad-network-for-developers-53k2</link>
      <guid>https://dev.to/salman_raja/why-im-building-a-privacy-first-asynchronous-ad-network-for-developers-53k2</guid>
      <description>&lt;p&gt;Let’s be honest: most modern ad networks are a complete nightmare for developers and privacy advocates. They rely on heavy, bloated tracking scripts, aggressive fingerprinting cookies, and invasive data collection. &lt;/p&gt;

&lt;p&gt;Worse yet, they frequently bottleneck website performance because of poorly optimized synchronous scripts. &lt;/p&gt;

&lt;p&gt;As developers, we are famously hostile toward invasive tracking. We block ads, we audit our network tabs, and we care deeply about user experience. But websites still need to find sustainable ways to monetize without selling out their users' data. &lt;/p&gt;

&lt;p&gt;That’s exactly why I decided to build &lt;strong&gt;AsynchAds Network&lt;/strong&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Problem with Traditional Ad Scripts
&lt;/h2&gt;

&lt;p&gt;When you drop a standard third-party advertising script onto a site, you are often surrendering control of your network tab. &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Render Blocking:&lt;/strong&gt; Synchronous scripts pause DOM parsing, slowing down your Core Web Vitals.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Privacy Nightmare:&lt;/strong&gt; Massive databases cross-reference user data across thousands of sites to build invasive behavioral profiles.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Bloat:&lt;/strong&gt; Extra tracking pixels, telemetry reporting, and redirection chains inflate bundle sizes.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  How AsynchAds Changes the Formula
&lt;/h2&gt;

&lt;p&gt;I wanted to build an ad platform that treats developers and users with respect. The core pillars are simple:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Strictly Asynchronous Execution:&lt;/strong&gt; The ad payload loads entirely in the background. It will never block your page layout, delay your hydration cycles, or compromise your performance budgets.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Zero Tracking Cookies:&lt;/strong&gt; No cross-site tracking, no fingerprinting, and no profile aggregation. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Context-Driven Targeting:&lt;/strong&gt; Instead of tracking &lt;em&gt;who&lt;/em&gt; the user is across the internet, ads are served solely based on &lt;em&gt;what&lt;/em&gt; content is on the page. If a user is reading a React tutorial, they see tools relevant to frontend developers. Simple, fast, and respectful.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  What’s Next?
&lt;/h2&gt;

&lt;p&gt;AsynchAds is built specifically to integrate cleanly into modern web applications without dragging down your performance scores. &lt;/p&gt;

&lt;p&gt;I’m currently gathering feedback from early-stage developers, open-source maintainers, and independent creators who want to explore monetization without breaking their users' trust. &lt;/p&gt;

&lt;p&gt;I'd love to hear your thoughts: How do you handle site monetization today? What features or strict guardrails would make you comfortable putting an ad network on your own platform?&lt;/p&gt;

&lt;p&gt;Let's discuss in the comments below!&lt;/p&gt;

</description>
      <category>buildinpublic</category>
      <category>privacy</category>
      <category>startup</category>
      <category>webdev</category>
    </item>
    <item>
      <title>How we built a 3.4 KB ad script with 0.03 CLS using Cloudflare Workers</title>
      <dc:creator>Salman Raja</dc:creator>
      <pubDate>Tue, 03 Nov 2026 07:58:12 +0000</pubDate>
      <link>https://dev.to/salman_raja/how-we-built-a-34-kb-ad-script-with-003-cls-using-cloudflare-workers-5788</link>
      <guid>https://dev.to/salman_raja/how-we-built-a-34-kb-ad-script-with-003-cls-using-cloudflare-workers-5788</guid>
      <description>&lt;p&gt;If you run a developer blog, you know the absolute dread of adding a traditional display ad network. You spend months optimization-tuning your site to hit a perfect mobile Lighthouse score, only to watch a legacy tracking script pull down 100 KB of third-party bloat, thrash the DOM, destroy your Interaction to Next Paint (INP), and wreck your web vitals.&lt;/p&gt;

&lt;p&gt;We got tired of this trade-off, so we built AsynchAds—a privacy-first sponsorship network tailored exclusively for tech blogs and documentation sites.&lt;br&gt;
To prove it’s possible to monetize without ruining user experience, we open-sourced our operational metrics. Here is the technical breakdown of how we optimized our client-side footprint down to a microscopic 1-3 KB:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Decoupling Compute from Origin via Cloudflare Workers&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Instead of relying on heavy corporate analytics pipelines or database lookups on the client-side, we route everything through Cloudflare Workers.&lt;br&gt;
• Ad requests are evaluated globally at the edge close to your reader.&lt;br&gt;
• The Worker computes geographic targeting, checks campaign status, and renders payload structures instantaneously.&lt;br&gt;
• Images are compressed dynamically into highly optimized WebP and PNG assets under 150 KB.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Bulletproof Telemetry via navigator.sendBeacon&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Traditional tracking scripts register click logs by spinning up continuous event loops that choke the browser's main thread. We completely bypassed this by utilizing navigator.sendBeacon. When a reader clicks a sponsored card, the click data is dispatched out-of-band as an asynchronous background request. The user experiences 0ms interaction lag, protecting your site’s INP.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Viewport-Aware Impressions via IntersectionObserver&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;We don't believe in cheating advertisers by firing impression pixels the split-second a page mounts. Our vanilla script hooks into the native browser IntersectionObserver API with a strict 0.01 threshold. The payload tracking only triggers when a reader actually scrolls the placement into view.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Safe Failures with 0 Cumulative Layout Shift (CLS)&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;If a user is browsing via an aggressive network-level firewall (like a Pi-hole) or loses connection entirely, our script catches the network error gracefully:&lt;/p&gt;

&lt;p&gt;*&lt;em&gt;.catch(() =&amp;gt; {&lt;br&gt;
  container.style.display = "none";&lt;br&gt;
});&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Because the CSS containers match strict, predictable aspect ratios, the ad container collapses instantly and invisibly if a fetch fails. Your text content flows together perfectly—no broken image graphics, no awkward loading states, and no layout shifting.&lt;/p&gt;

&lt;p&gt;Check out our raw site performance or audit our live placements directly on our Website. &lt;br&gt;
We built this because developers deserve a fast web.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>javascript</category>
      <category>architecture</category>
      <category>showdev</category>
    </item>
  </channel>
</rss>
