After revisiting the question, I decided to provide a completely different response.
Dealing with CSS is primarily declarative, which offers significant convenience. When you declare a style, you don't have to worry about reapplying it to new elements or reprocessing the DOM. Changes happen seamlessly within the browser. On the other hand, imperatively altering new elements every time a modification occurs can be cumbersome and prone to errors. Therefore, there isn't a universal event for "async loaded elements" and it's advisable not to seek one.
Benefits of Caching
In a web environment, keeping a constant CSS file is generally a good practice. The browser caches the CSS, allowing it to be quickly retrieved when needed. If you make changes to your CSS, the browser might not detect them immediately. While there are various considerations to keep in mind, this holds true in most scenarios.
So, even if you edit your CSS file, unless you directly inform the browser of the change, it may not take notice.
One technique called cache-busting involves adding a GET parameter after the CSS link, for example:
<link href="https://www.famous-cats.com/style/puna.css?v=3" rel="stylesheet" type="text/css" />
The browser perceives ?v=1 as distinct from ?v=2, leading it to cache versions with different GET parameters even if they reference the same file.
Modifying Files
However, is it advisable to directly alter the CSS file itself? If 95% of the rules remain consistent each time (except for specific color changes), it might be beneficial to segregate them into a "main" file and manage color-related rules separately in a different file or inline in the HTML.
Another consideration when changing files is whether you intend to generate new styles programmatically. If not, maintaining constant files and switching between them might be more efficient.
DOTLESS
DOTLESS is an asp.net port of LessCSS. For its features, visit , where you'll find it shares similarities with Sass but with a slightly different syntax.
One advantage is the ability to use variables and retrieve their values from URL parameters. For instance, linking to style.less?color=fuschia will assign the value of the variable "color" to your preferred shade.
Less is a valuable tool that can significantly streamline development.
The Recommended Solution
A practical approach is to handle color modifications in a separate CSS file:
<link href="https://www.famous-cats.com/style/main.css" rel="stylesheet" type="text/css" />
<link href="https://www.famous-cats.com/style/color.less?color=00FF55" id="colorcss" rel="stylesheet" type="text/css" />
To change colors, simply use:
document.getElementById('colorcss').href = 'color.less?color=F35741';
(I've assigned an id to the link tag).
This method works effectively.
Explore Less further to understand how you can employ color variables. You can enable administrators to easily select a specific color.
Remember, inline CSS can be useful and creating it in Razor is straightforward. For a few rules, it's a viable option. If you're not using Less, consider inline CSS or generate CSS through an MVC controller-action (set the MIME type to text/css and utilize a URL parameter for color changes or cache busting).
I trust this addresses your query.