Search code examples
javascripthtmlcssvimeofavicon

how to update a favicon, vimeo style


Vimeo has this nice favicon that changes while uploading a video, it shows the amount of uploaded content in a pie chart style favicon. Can someone point me in the right direction of how to create such a thing?


Solution

  • Just change the <link> to the favicon through normal DOM methods.

    See a live example:

    <link rel=icon href="http://www.bluejag.co.uk/favicon.ico">
    <!-- ... -->
    <script>
    function changeFav() {
      document.querySelector('link[rel=icon]').href = "http://www.solaripedia.com/favicon.ico";
    }
    document.querySelector('input').addEventListener('click', changeFav);
    </script>