I Built a Popup That Sends My Commission Back to the Buyer

BackerLeader ●2 ●11 ●62
calendar_today ago • schedule2 min read

Originally published on bryanhamilton.info - full code at github.com/bryanhamiltondev/holiday-lightbox

Every affiliate link on the internet comes pre-packaged with the same lie: "I only recommend products I love." Meanwhile the link is a paycheck. Readers know it. You know it. I know it.

So for this year's Christmas promo on my site I tried the only version of that sentence that's actually true: I recommend these headphones, I do get a commission, and I hand every dollar of it back to whoever buys. Buy through my link, forward your order receipt, and my entire commission goes back to you as cash. I keep zero. The referral money becomes a discount that doesn't need the merchant's permission.

The feature itself is a promo lightbox, and I open-sourced the production code because the implementation turned out to be more interesting than the marketing angle:

  • Zero dependencies. One HTML block pasted before . No framework, no fetch, no cookies, no build step.
  • It sells by date, not by nag. A date window gates the whole thing: it opens itself in November, shows through December 24, then never opens again. No cron, no takedown deploy. (I still wrote a takedown worker, because deleting things is fun.)
  • It waits its turn. Opens 1.4 seconds after load, not on first paint. My homepage LCP is around 2.3s and I'm not letting a popup fight it for the metric.
  • Three exits: close button, backdrop click, Escape key.
  • It respects prefers-reduced-motion. Every animation - card entry, light glow, bulb blink - dies for users who ask for it. It's a sales popup, not a seizure test.
  • A JSON-LD Product block rides along, so the offer is machine-readable from day one: price, currency, stock, offer URL.

The one design detail I'm weirdly proud of: the string of Christmas lights hanging from the inside top edge of the card. Bulb positions sit on a sine curve so the wire sags believably, drop heights vary, colors rotate through a five-color palette, and the whole strand rebuilds itself on resize. About 30 lines of vanilla JS, because I refuse to pull in a dependency for decorative blinking.

Honest notes, since honesty is the whole theme here:

  1. It reopens on every page load during the window. Deliberate, for a four-week campaign. If yours runs longer, add a sessionStorage guard.
  2. The cashback promise is operational debt. Someone has to answer those receipt emails and actually send money back. If you copy this pattern, budget for it - a broken cashback promise is worse than no offer at all.
  3. The FTC disclosure lives inside the cashback line itself. "I'll send my entire commission to you" IS the disclosure. I deleted the boilerplate sentence and let the honest sentence do that job.

The code is at github.com/bryanhamiltondev/holiday-lightbox - src/lightbox.html is the verbatim production block, docs/index.html is a standalone demo you can open locally and watch it pop.

Question for the comments: does the cashback hook make you more likely to click a referral link, or does it read as a gimmick? I honestly can't tell if this is clever or if I've invented a slower discount code.

Want more #frontend & #php deep dives?

Join 6,093+ developers sharing real benchmarks, code breakdowns, and projects. Free forever.

7 Comments

1 vote
0
0 votes
0
0
0
0

More Posts

How I Built a React Portfolio in 7 Days That Landed ₹1.2L in Freelance Work

Dharanidharan - Feb 9

Cloudflare Blocked My Server, So I Made My Visitors' Browsers Do the Fetching

bryanhamiltondevverified - Nov 15

A coach complained, so I built sports academy management software

rahuldk1105 - Oct 26

PHP2Shell: Two 9.2-Rated Flaws Reach Back to PHP 5. Here's the Plan for EOL Teams

Tom Smithverified - Oct 22

Everyone says DeepSeek is cheaper, but I got tired of guessing the exact math. So I built a calculat

abarth23 - Apr 27
chevron_left
3.7k Points • 75 Badges
Rochelle Park, New Jersey, US • bryanhamilton.info
32Posts
42Comments
36Connections
Full-stack web engineer · PHP & vanilla JS · 25+ years · Founder of The DJ Calendar · Open to work

Related Jobs

View all jobs →

Commenters (This Week)

16 comments
5 comments
1 comment

Contribute meaningful comments to climb the leaderboard and earn badges!