简体   繁体   English

为Phonegap应用优化图像

[英]Optimizing images for Phonegap app

Optimizing images for native development on iOS is pretty straight forward just using image catalogs for the different devices and resolutions but in Javascript what are the optimization techniques? 仅针对不同设备和分辨率使用图像目录,就可以很轻松地为iOS上的本机开发优化图像,但是在Javascript中,优化技术是什么? Is it best practice to save a bunch of the same image out at different resolutions and pick the best image based on the device size? 最佳做法是将一堆相同的图像保存为不同的分辨率,然后根据设备大小选择最佳图像吗? How do you go about doing this efficiently? 您如何有效地做到这一点? I'm developing this application to release on both iOS and Android so how should I be optimizing my images so that I have the best quality while also maintaining small application size and best performance? 我正在开发要在iOS和Android上发布的应用程序,那么我应该如何优化我的图像,以便在保持较小的应用程序大小和最佳性能的同时获得最佳质量?

I'm not a Phonegap expert, but AFAIK you use HTML for the interface. 我不是Phonegap专家,但是AFAIK您使用HTML作为界面。 In that case, I think you'd look for <picture> , in particular the sub-tag <source> and its srcset and media attributes. 在这种情况下,我认为您会寻找<picture> ,尤其是子标签<source>及其srcsetmedia属性。

See more at MDN: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/picture 在MDN上查看更多信息: https : //developer.mozilla.org/en-US/docs/Web/HTML/Element/picture

If these images are like icons or other vector-type images, then use scalable SVG. 如果这些图像类似于图标或其他矢量类型的图像,请使用可缩放的SVG。

If they are PNG or JPG, then make the images large, like 1000px, but compress 50%. 如果它们是PNG或JPG,则将图像放大,例如1000px,但压缩50%。 They'll look fine at large sizes and terrific at smaller sizes. 大尺寸时看起来不错,小尺寸时效果很好。

Also, integrate lazy loading of images if the user must scroll down to see a lot of them. 另外,如果用户必须向下滚动才能看到很多图像,则集成图像的延迟加载。 With lazy loading, they load only when they are coming into view. 使用延迟加载,它们仅在可见时加载。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM