Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/rumkin/favicon-switcher
Make favicon react on media queries
https://github.com/rumkin/favicon-switcher
favicon site theming ui utils
Last synced: 3 months ago
JSON representation
Make favicon react on media queries
- Host: GitHub
- URL: https://github.com/rumkin/favicon-switcher
- Owner: rumkin
- License: mit
- Created: 2019-09-09T05:30:13.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2020-01-17T14:42:28.000Z (almost 5 years ago)
- Last Synced: 2024-07-03T20:59:17.708Z (4 months ago)
- Topics: favicon, site, theming, ui, utils
- Language: JavaScript
- Homepage: https://rumkin.github.io/favicon-switcher/
- Size: 71.3 KB
- Stars: 80
- Watchers: 3
- Forks: 4
- Open Issues: 2
-
Metadata Files:
- Readme: readme.md
- License: license
Awesome Lists containing this project
README
# Favicon Switcher
[Live preview](https://rumkin.github.io/favicon-switcher)
Switches site's favicon by matching media queries. It could be used for
light/dark mode switching. Due to browsers don't support all Media Query
features in link tag, this module fixes it.## Usage
Script doesn't require any setup or configuration and works like a polyfill.
The example below shows how to make dark/light mode icon switching.Use the main library to automatically turn icon switching on:
```html
```
If you need more control to turn switching on and off use one of the next
module:### UMD
Use with UMD:
```html
faviconSwitcher()
```### ESM
Use as ES module:
```html
import initSwitcher from 'https://unpkg.com/[email protected]/dist/index.esm.js'
// Subscribe to media queries changing events
const unsubscribe = initSwitcher()
// Unsubscribe later on some condition. For example on page navigation.
unsubscribe()```
## Complete example
```html
```
## License
MIT © [Rumkin](https://rumk.in)