使用 HTML5 LocalStorage 存储字体/图像/流行插件
有人成功使用localStorage来存储CSS引用的字体文件吗?我该如何实现这个?
对于图像,我知道我可以对脚本中的图像进行二进制编码并保存到 localStorage 中,但这意味着非常大的脚本代码。如果每次都加载臃肿的脚本,我看不到任何真正的好处。如果将脚本缓存为单独的文件,则与首先缓存图像文件相同。我是否遗漏了一些东西,或者确实没有任何好处,这是 localStoraging 图像的正常情况。
任何人成功实现了 Facebook/Google/Twitter 上的 localStoraging 流行插件并愿意分享哪些是最有用/最适用于缓存的插件?
Has anyone used localStorage successfully to store font files referenced by CSS? How can I implement this?
For images, I know I can binary encode the images in script and save into localStorage, but that would mean a very large script code. If the bloated script is loaded everytime, I don't see any real benefit. If the script is cached as a seperate file, it would be the same as caching the image file in the first place. Am I missing something or there really is no benefit is normal circumstance for localStoraging images.
Anyone successfully implemented localStoraging popular plugins from Facebook/Google/Twitter and willing to share which are the ones most useful/applicable for caching?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我不知道您的浏览器支持要求是什么样的。
本文讨论在本地存储中存储图像。当然,它的速度非常快:
http://www.sencha.com/learn/take-sencha- touch-apps-offline/
至于字体,我正在考虑自己做。我会让您知道它是如何实现的:)
另外,请查看 caniuse.com 了解浏览器支持:
I have no idea what your browser support requirements are like.
This article talks about storing images in local storage. Of course it's insanely fast:
http://www.sencha.com/learn/taking-sencha-touch-apps-offline/
As for fonts, well I'm looking at doing that myself. I'll let you know how it works out :)
Also, check out caniuse.com for browser support:
希望这会有所帮助:
根据经验,我可以告诉你不要这样做。您可以使用 CSS3 @fontface,但这仍然会给您带来一些问题。我发现的最稳定的解决方案是使用 cufon: http://cufon.shoqolate.com/generate/.
我同意你的评估,并且我自己也进行了详细的探索。在大多数情况下,缓存的图像胜过编码的图像。
不,但只能想象这会给你的跨浏览器兼容性带来很多麻烦。
谢谢,
马特
Hope this helps:
From experience, I can tell you don't do it. You can use CSS3 @fontface, but that will still give you some issues. Most stable solution I have found is to use cufon: http://cufon.shoqolate.com/generate/.
I agree with your assessment and have explored it in detail on my own. Cached images beat encoded images in most cases.
No, but can only image that this will give you much grief in cross-browser compatibility.
Thanks,
Matt