<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>JavaScript on my docs</title><link>https://docs.tannerr.dev/javascript/</link><description>Recent content in JavaScript on my docs</description><generator>Hugo -- gohugo.io</generator><language>en-us</language><atom:link href="https://docs.tannerr.dev/javascript/index.xml" rel="self" type="application/rss+xml"/><item><title/><link>https://docs.tannerr.dev/javascript/js-snippets/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://docs.tannerr.dev/javascript/js-snippets/</guid><description>1. Download Every Image on a Page # Tired of right-clicking one by one?
[...document.images].forEach((img, i) =&amp;gt; { fetch(img.src) .then(res =&amp;gt; res.blob()) .then(blob =&amp;gt; { const a = document.createElement(&amp;#39;a&amp;#39;); a.href = URL.createObjectURL(blob); a.download = `image-${i}.jpg`; a.click(); }); }); 🖼️ Boom—your gallery’s yours now.
2. Turn Any Page Into a Rainbow Disco # Perfect for annoying your coworkers or freaking out your friends.
setInterval(() =&amp;gt; { document.body.style.backgroundColor = `hsl(${Math.floor(Math.random() * 360)}, 100%, 50%)`; }, 100); 🌈 Please use responsibly.</description></item><item><title/><link>https://docs.tannerr.dev/javascript/service_worker_cache/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://docs.tannerr.dev/javascript/service_worker_cache/</guid><description>Service Worker Cache Issue # The Problem # CSS changes weren&amp;rsquo;t appearing after refresh. It seemed to require 2+ refreshes to see updates.
Root Cause # The original fetch handler in sw.js had a bug:
1 return cachedResponse || fetchPromise; Issue: JavaScript&amp;rsquo;s short-circuit evaluation. When cachedResponse exists:
Returns cached (stale) response immediately fetchPromise runs in background and updates cache for the next request User sees old content until they refresh again This is why 2 refreshes were needed.</description></item></channel></rss>