loadCssFile()
Injects a stylesheet by appending a <link rel="stylesheet"> to document.head. Resolves when the sheet fires load; rejects on error (e.g. 404 or network failure).
Id replacement: if attrubutes.id is set, any existing element with that id is removed first, so repeated calls with the same id replace the previous link (useful for theme or font URLs that change).
If rel is omitted in attrubutes, it defaults to stylesheet. Other attributes (crossorigin, media, data-*, etc.) are set via setAttribute from the record entries.
Examples:
ts
await loadCssFile('https://example.com/fonts.css', {
id: 'app-fonts',
crossOrigin: 'anonymous',
});ts
// Swap theme stylesheet without duplicate link tags
await loadCssFile('/themes/dark.css', { id: 'theme' });
await loadCssFile('/themes/light.css', { id: 'theme' });