创建一个自包含的脱机HTML5应用程序以及嵌入其资源的最佳方法 [英] Creating a self contained, offline HTML5 app and the best method for embedding its resources

查看:94
本文介绍了创建一个自包含的脱机HTML5应用程序以及嵌入其资源的最佳方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试创建一个文件HTML5文档,该文档可以通过电子邮件发送给包含运行它所需的所有标记,js,css和图像的人.

I am trying to create a single file HTML5 document that can be emailed to people that would contain all markup, js, css and images needed to run it.

我知道一些描述离线过程的文章,例如 http://diveintohtml5.info/offline.html,但是想知道嵌入其资源(例如大图像和js文件)的最佳方法.

I am aware of articles describing the offline process such as http://diveintohtml5.info/offline.html, however would like to know the best method to embed its resources such as large images and js files.

我会使用base64编码还是有更好的方法?

Would I be using base64 encoding for these or is there a better approach?

应用程序将在相当新的浏览器上运行.

App will be running on fairly new browsers.

推荐答案

是的,base64对图像进行编码.我要做的是将它们另存为png并保存为正确的大小,然后再转换为base64(有免费的在线网站为您完成此操作).这样可以节省大量空间.

Yes, base64 encode the images. What I do is save them as png and to the correct size before converting to base64 (there are free online sites that do it for you). This saves a lot of space.

要将数据保存到本地文件,请使用HTML5本地存储,这是一个指南: http://www.html5rocks.com/en/features/storage .

For saving data to localfile, use HTML5 local storage, here is a guide: http://www.html5rocks.com/en/features/storage.

对于JS/CSS文件,只需将它们粘贴在头上,没什么大不了的!

For the JS/CSS files, just paste them in the head, no biggie!

这篇关于创建一个自包含的脱机HTML5应用程序以及嵌入其资源的最佳方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆