如何在部署时动态更改 CSS 文件中图像的 src 属性? (ASP.NET Web 表单)
我正在创建一个 ASP.NET Web 窗体网站,我需要优化该网站的加载时间。其中一种方法是从不同的服务器加载图像。
对于通过 aspx 页面或用户控件公开的所有图像,我使用一种实用程序将资源的相对链接转换为绝对链接,链接到首选服务器资源。
我需要能够对从 CSS 文件加载的图像执行相同的操作,这意味着对于将从 css 文件加载的每个图像,我需要将 src 属性更改为首选属性。你知道有什么工具可以做到这一点,或者我可以应用任何解决方案来解决我的问题吗???
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 images 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 ???
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
有几个选项:
有多种方法可以执行以下任一操作:上述的。以下是一些可能会给您一些想法的链接:
或者您甚至可以使用 ASP.NET主题支持两个主题,一个用于开发,一个用于生产。虽然我不确定这是一个很好的选择。
There are a couple of options:
There are a number of ways of doing either of the above. Here are some links that might give you some ideas:
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.