Carregamento dinâmico de CSS

Estou tentando criar uma função de tema de página para o meu site. Quero carregar os temas correspondentes dinamicamente na página usando arquivos CSS separados.

Estou usando este código:

  fileref.setAttribute("rel", "stylesheet")
  fileref.setAttribute("type", "text/css")
  fileref.setAttribute("href", 'link.css')

  document.getElementsByTagName("head")[0].appendChild(fileref)

O que funciona bem, mas não retorna nenhuma informação se o arquivo CSS foi carregado ou não.

Existe uma maneira de capturar quando o.css está carregado? Talvez usando ajax?

questionAnswers(1)

yourAnswerToTheQuestion