Mastodon

multidisciplinary creative and full-stack developer

Menu
about
me
contact
links
journal
writings
social
posts
bookmarks
saves
news
breaking
projects
portfolio
uses
tools & stack
startyparty
homepage

Find the Icon or Favicon on A Website

October 20, 2024

I use this snippet sometimes when my automated scripts are unable to fetch the icon or favicon from a website. Here's a quick and simple way to find the icon or favicon on a website:

Open up your browser's console Command + Option + J on macOS or Ctrl + Shift + J on Windows and Linux.

Then paste the following code into the console:

var _icon = document.getElementsByTagName("link"); for (var i = 0; i < _icon.length; i++) { var link = _icon[i]; var rel = link.getAttribute("rel"); if (rel === "apple-touch-icon" || rel === "icon") { console.log(link.getAttribute("href")); } }

Here's what it returns on github.com:

https://github.githubassets.com/favicons/favicon-dark.svg https://github.githubassets.com/favicons/favicon.png

Hope you find this useful.

tags
ProgrammingSoftwareJavascriptConsole
Contact & Social
© 2008 - 2026 Marko Bajlovic
Version5.11.3