automagically grab the favicon of a url
add this to your html:
<img loading="lazy" src="https://favicon.jaw.dev?url=<url>" />Note
the first request will be slow, but the subsequent requests will be cached.
-
First Request (Cache Miss):
- Extracts the domain from the provided URL
- Attempts to fetch favicon from multiple common locations in parallel:
/favicon.ico,/favicon.png,/favicon.svg- Apple touch icons
- Web app manifest icons
- Returns the first successful match (within 1.5 second timeout)
- Optimizes images by resizing to 16x16 if needed
- Stores the favicon in SQLite database with 24-hour expiration
- Returns the favicon with
X-Favicon-Source: fetchedheader
-
Subsequent Requests (Cache Hit):
- Checks database for cached favicon
- If found and not expired, returns immediately
- Response includes ETag for browser caching
- Returns with
X-Favicon-Source: cachedheader - Much faster than initial fetch (~3µs vs 500ms+)
-
Fallback:
- If no favicon found after timeout, returns a default favicon
- Response includes
X-Favicon-Source: defaultheader
Fetches the favicon for a given URL.
Parameters:
url(required): The URL to fetch the favicon for
Example:
https://favicon.jaw.dev?url=github.com
Lists all cached favicons in the database.
Parameters:
format(optional): Response format- Default: HTML table view
json: Returns JSON array
HTML Response:
Returns an HTML table with the following columns:
id: Database IDdomain: Cached domaindata: Favicon preview with size in bytescontent_type: MIME type of the faviconcreated_at: Timestamp when cached
JSON Response:
curl https://favicon.jaw.dev/domains?format=jsonReturns JSON array:
[
{
"id": 1,
"domain": "github.com",
"data_size": 5430,
"content_type": "image/png",
"created_at": "2025-10-15 04:55:40"
}
]Health check endpoint. Returns ok if the service is healthy.
- See DEVELOPMENT for
developmentguide. - See CONTRIBUTION for
contributionguide.
Distributed under the MIT License © wajeht. See LICENSE for more information.