Tristan Sweeney

← Back to blog

Favicon Fun

Published on 2024-9-17 by Tristan Sweeney

photo by Astro
I love the Astro homepage favicon effect, and replicated it on my site.

You can get more creative with the effect, only enabling it on desktop via testing css breakpoints, but I think simple is best.

<script>
// https://stackoverflow.com/questions/260857/changing-website-favicon-dynamically/260876%23260876
const icon = document.querySelector < HTMLLinkElement > "link[rel~='icon']";
if (icon) {
window.onblur = () => {
icon.type = "image/png";
icon.href = "/sauron.png";
};
window.onfocus = () => {
icon.type = "image/x-icon";
icon.href = "/favicon.ico";
};
}
</script>

Written by Tristan Sweeney

← Back to blog
  • Favicon Fun

    9/17/2024
    Favicon Fun
    photo by Astro

    I love the Astro homepage favicon effect, and replicated it on my site.

  • Ransom Note

    5/3/2020
    Ransom Note
    photo by Jamie Eckle

    Given the text for a ransom note, determine if enough letters exist in a magazine to create it.

  • Breaking down Subsum Equals K

    4/29/2020
    Breaking down Subsum Equals K
    photo by Meghan Vestal

    given an array of integers, find the number of continuous subarrays equal to `k`.

  • Revivifying the Blog

    4/11/2020
    Revivifying the Blog

    I recently had a friend come across my blog, and was promptly shamed for having a certificate more out of date than the VCR. Such an embarrassment couldn't rest, and so I cleaned up my act a bit.

  • Apt install on a Disconnected Wireless System

    6/8/2018
    Apt install on a Disconnected Wireless System
    photo by Google

    I just was installing ubuntu on a platform that only has wireless capabilities, and decided to install the server edition to minimize overhead / avoid having an X server + desktop environment to disable. Woe, the server edition of Ubuntu ships with no wireless utilities, because nobody in their right mind would run a wireless server.

  • Let's Encrypt HTTPS on DD-WRT

    6/5/2018
    Let's Encrypt HTTPS on DD-WRT
    photo by DD-WRT

    I run a DD-WRT router on a Netgear WNDR4500 router. It's been in my life since I can remember, and came along with me to college. A while back I loaded the DD-WRT firmware onto it, and it's been serving like a champ ever since.