生成动态图像的CSS sprites [英] Generating CSS sprites for dynamic images
问题描述
我有一个网页,其中包含大约20 - 50个动态图片(由非静态来源提供的图片)。这些图像通过基于请求URL的servlet提供。
I have a webpage which contains about 20 - 50 dynamic images (images served from a non-static source). These images are served through a servlet based on the request URL. This results in a request being generated per image, which leads to performance decay.
如果这些图像是静态的,我将创建一个CSS sprite,并将50个请求替换为单一。因为它们是动态的,这当然不是那么容易。我正在寻找一个工具/库/方法,我可以使用,以便将这些图像聚合成单个sprite在运行时。幸运的是图片大小是不变的,所有的图片大小都是一样的,这应该会更容易。
If these images were static, I would create a CSS sprite and replace the 50 requests with a single one. As they are dynamic this is not that easy of course. I'm looking for a tool/library/method that I can use in order to aggregate these images into a single sprite at runtime. Luckily image size is constant and the same for all, which should make this much easier.
有任何建议吗?
推荐答案
您可以检查并尝试jawr( https://jawr.dev .java.net / )库,用于在servlet上生成/修改(也压缩,合并)css文件。它具有动态改变背景图像的选项。
您可以安排用于切换css文件的包,用于更改皮肤。
You can check and try jawr (https://jawr.dev.java.net/) library for generating/modifying (also compressing, merging) css files on servlet. It has option to change background images dynamically. You may arrange bundles for switching css file(s) for changing skin(s).
正面:您还可以管理和排列.js文件太!
Plus side: You can also manage and arrange your .js files too!
这篇关于生成动态图像的CSS sprites的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!