使用 HTML5 LocalStorage 存储字体/图像/流行插件

发布于 2024-12-21 07:00:18 字数 341 浏览 4 评论 0原文

  1. 有人成功使用localStorage来存储CSS引用的字体文件吗?我该如何实现这个?

  2. 对于图像,我知道我可以对脚本中的图像进行二进制编码并保存到 localStorage 中,但这意味着非常大的脚本代码。如果每次都加载臃肿的脚本,我看不到任何真正的好处。如果将脚本缓存为单独的文件,则与首先缓存图像文件相同。我是否遗漏了一些东西,或者确实没有任何好处,这是 localStoraging 图像的正常情况。

  3. 任何人成功实现了 Facebook/Google/Twitter 上的 localStoraging 流行插件并愿意分享哪些是最有用/最适用于缓存的插件?

  1. Has anyone used localStorage successfully to store font files referenced by CSS? How can I implement this?

  2. 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.

  3. Anyone successfully implemented localStoraging popular plugins from Facebook/Google/Twitter and willing to share which are the ones most useful/applicable for caching?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

ぽ尐不点ル 2024-12-28 07:00:18

我不知道您的浏览器支持要求是什么样的。

  1. localStorage 适用于 IE8+。
  2. @font-face 有不同的支持,但 IE9+ 支持 WOFF 字体。
  3. 我认为您需要对字体进行 Base64 编码才能与 localStorage 一起使用。
  4. dataUri(base64 字体所需)在 IE8 中具有大小限制(我相信它是 32k)。
  5. 如果你问我的话,库丰真的很糟糕。就我而言,要么是 WOFF 支持,要么什么都没有。

本文讨论在本地存储中存储图像。当然,它的速度非常快:
http://www.sencha.com/learn/take-sencha- touch-apps-offline/

至于字体,我正在考虑自己做。我会让您知道它是如何实现的:)

另外,请查看 caniuse.com 了解浏览器支持:

I have no idea what your browser support requirements are like.

  1. localStorage works in IE8+.
  2. @font-face has varying support, but IE9+ supports WOFF fonts.
  3. I think you'd need to base64 encode your fonts for them to work with localStorage.
  4. dataUri's (required for base64'd fonts) have size limitations in IE8 (I believe it's 32k).
  5. Cufon seriously sucks if you ask me. In my case it's WOFF support or nothing.

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:

执妄 2024-12-28 07:00:18

希望这会有所帮助:

  1. 根据经验,我可以告诉你不要这样做。您可以使用 CSS3 @fontface,但这仍然会给您带来一些问题。我发现的最稳定的解决方案是使用 cufon: http://cufon.shoqolate.com/generate/.

  2. 我同意你的评估,并且我自己也进行了详细的探索。在大多数情况下,缓存的图像胜过编码的图像。

  3. 不,但只能想象这会给你的跨浏览器兼容性带来很多麻烦。

谢谢,

马特

Hope this helps:

  1. 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/.

  2. I agree with your assessment and have explored it in detail on my own. Cached images beat encoded images in most cases.

  3. No, but can only image that this will give you much grief in cross-browser compatibility.

Thanks,

Matt

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文