Changing favicon with notebook extension

New to notebook extensions and most all web development concepts here. I’m attempting to change JupyterLab’s favicon using this cookiecutter theme, with the ultimate goal of being able to change the favicon based on a config file. I’m using a slight modification of this SOF post, included within my src/index.ts file.

let head = document.head || document.getElementsByTagName('head')[0];

function changeFavicon(src: string) {
  let link = document.createElement('link'),
       oldLink = document.getElementById('dynamic-favicon'); = 'dynamic-favicon';
  link.rel = 'icon';
  link.type = 'image/x-icon';
  link.href = src;
  if (oldLink) {

When I call…


…the favicon changes appropriately. But how would I access a favicon.ico file stored within my very own local extension directory?

A step further, how could I change the path to different favicon files using a config file?

Thanks for the snippet! As per how to make my own extension with static files listed - this is a good example jupyterlab/jupyterlab - Gitter.