ios开发放大缩小动画_使缩小成为HTML开发过程的一部分

ios开发放大缩小动画

Making a website page load faster is, at least in part, a question of page size. Page size, in turn, is a function of how much code and content you have in a web document. Content you can always reduce by editing and tightening up your writing, reducing the number of words on each page; code you reduce by eliminating redundant, optional, or unnecessary markup, , or scripts. Every character that you can remove from your page saves you a byte on the final file size. While this may make only a fractional difference to an individual visitor, it really adds up over hundreds or thousands of page views, and becomes especially important if you are paying for your site hosting per download.

使网站页面加载更快至少部分是页面大小的问题。 反过来,页面大小取决于Web文档中有多少代码和内容。 您始终可以通过编辑和加强写作来减少内容 ,减少每页上的单词数; 通过消除冗余,可选或不必要的标记, 脚本来减少的代码 。 您可以从页面中删除的每个字符都会为您节省最终文件大小的一个字节。 尽管这可能对单个访问者只产生很小的差别,但实际上它增加了成百上千的页面浏览量,如果您要为每次下载支付站点托管费用,则尤为重要。

There are a number of tools that can “minify” HTML. However, you can start the process as you write the code, especially if you are writing HTML5. Since HTML5 minifiers are still in their infancy, this is a step that you must often take for yourself.

有许多工具可以“缩小” HTML 。 但是,您可以在编写代码时开始该过程,尤其是在编写HTML5时 。 由于HTML5缩小程序仍处于起步阶段,因此您必须经常亲自完成这一步骤。

  • The following closing tags are optional in HTML5, and can be dropped.

    以下结束标记在HTML5中是可选的,可以删除。
  • </li>, </dt>, </dd>, </tr>, </th>, </td>, </thead>, </tfoot>, </tbody>, </option>, </optgroup>, </p> (in most cases), </head>, </body>, </html>

    </li></dt></dd></tr></th></td></thead></tfoot></tbody></option></optgroup></p> (在大多数情况下), </head></body></html>

  • (Note that many tools, such as , will needlessly auto-complete and close your code by default, meaning you will have to use find-and-replace to remove these tags after the page is complete):

    (请注意,默认情况下,许多工具(例如 )将不必要地自动完成并关闭您的代码,这意味着您必须在页面完成后使用查找替换来删除这些标签):

  • Attribute values only need to use quotations if the value contains spaces or some non-alphanumeric characters (such as a question mark). So <div id=wrapper> is legitimate, as is <img src=assets/images/falls.jpg …> but <img alt=Angel Falls …> is not. (Note that DreamWeaver, etc will automatically quote all attribute values by default).

    如果属性值包含空格或某些非字母数字字符(例如,问号),则仅需要使用引号。 因此, <div id=wrapper>是合法的, <img src=assets/images/falls.jpg …><img alt=Angel Falls …>是不合法的。 (请注意,DreamWeaver等默认情况下会自动引用所有属性值)。

  • You can shorten external links by dropping optional parts of the URL and eliminating the http: at the start.  So <a href="http://www.example.com/index.html"> becomes <a href=//example.com>

    您可以通过删除URL的可选部分并在开头消除http:来缩短外部链接。 因此<a href="http://www.example.com/index.html">变为<a href=//example.com>

  • Avoid unnecessary classes and ids: try to use CSS that does not require additions to your markup, such as .

    避免使用不必要的类和ID:尝试使用不需要在标记中添加内容CSS,例如

  • Replace divs with classes and ids with appropriate HTML5 semantic containers.

    使用适当的HTML5语义容器将div替换为类和ID。

  • Remember that HTML5 does not require self-closing tags. So there’s no need for <img /> or <hr /> : instead, use <img> and <br>.

    请记住,HTML5不需要自动关闭标签。 因此,不需要<img /><hr /> :而是使用<img><br>

  • Replace HTML entities with appropriate UTF-8 characters, where possible: for example, replace &ldquo; with characters.

    在可能的情况下,将HTML实体替换为适当的UTF-8字符:例如,替换&ldquo; 带有字符。

  • Remove carriage returns and newlines from your code. (This is often easier with a minify application.) If your content is in MySQL, you can use a SELECT:

    从代码中删除回车符和换行符。 (使用minify应用程序通常更容易。)如果内容在MySQL中,则可以使用SELECT

    UPDATE table SET field = REPLACE(field,'\n', '')
    UPDATE table SET field = REPLACE(field,'\r', '')

You’ll probably want to keep a version of your page with returns still in place, to make editing easier.

您可能希望保留页面的版本,并保持原样,以使编辑更加容易。

At the end of this process, you can easily save 15 – 20% on your HTML file size.

在此过程结束时,您可以轻松节省HTML文件大小的15 – 20%。

翻译自: https://thenewcode.com/502/Make-Minification-Part-of-Your-HTML-Development-Process

ios开发放大缩小动画

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值