1
0
mirror of https://github.com/nolanlawson/pinafore synced 2024-12-11 09:45:24 +01:00
Pinafore-Web-Client-Frontend/routes/_utils/setFavicon.js
2018-04-11 20:30:38 -07:00

18 lines
460 B
JavaScript

// borrowed from https://github.com/HenrikJoreteg/favicon-setter
export function setFavicon (href) {
let faviconId = 'theFavicon'
let oldLink = document.getElementById(faviconId)
if (oldLink.getAttribute('href') === href) {
return
}
let link = document.createElement('link')
link.id = faviconId
link.rel = 'shortcut icon'
link.type = 'image/png'
link.href = href
document.head.removeChild(oldLink)
document.head.appendChild(link)
}