/html-dom /Intermediate
GitHub 5008★

Load a CSS file dynamically

// Create new link element
const link = document.createElement('link');
link.setAttribute('rel', 'stylesheet');
link.setAttribute('href', '/path/to/js/file.css');

// Append to the `head` element
document.head.appendChild(link);

See also

Follow me on and to get more useful contents.