how to change, in CSS files, src attribute for images dynamically at deploy? (ASP.NET Web Forms)
I am creating an ASP.NET Web Forms website and I need to optimze the loading time of the website. One of the methods will be to make images load from dfferent servers.
For all i开发者_如何学Cmages exposed through aspx pages or user controls I use an utility that transforms the relative link of the resourses into an absolut one, linking to the preferred server resource.
I need to be able to do the same thing with images loaded from CSS files, meaning that for each image that is going to be loaded from the css file I need to change the src attribute to a prefered one. Do you know any tool that will do this, or any solution I can apply for my problem ???
There are a couple of options:
- Transform the CSS files at build time and serve them as static files
- Make the CSS files dynamic and let ASP.NET populate the paths to the images based on your existing setting
There are a number of ways of doing either of the above. Here are some links that might give you some ideas:
- Making Dynamic CSS content with ASP.NET
- LESS- The dynamic stylesheet language
Or you could even use ASP.NET Theming support to have two themes, one for development and one for production. Though I'm not sure that's a great option.
精彩评论