search
HomeWeb Front-endHTML TutorialDetailed explanation of examples of html page optimization
Detailed explanation of examples of html page optimizationJul 27, 2017 am 09:57 AM
htmloptimizationExample

1. Reduce the number of HTTP requests.

(1) Merge JS files and CSS files.

(2) Merge frame images and relatively less changed images into one, and complete rendering through CSS background cutting.

(3) Reasonably use local Cache to cache JS/CSS/IMAGE.

2. Reduce the size of the requested file and reduce the network bandwidth occupied by the requested data.

(1) Compress JS volume: delete blank line breaks, comments, and obfuscation in JS, and replace long variables with short variables.

(2) Compress CSS volume: delete CSS comments and use abbreviations as much as possible.

(3) Use (X)HTML+CSS to build the website structure and provide CSS reusability to reduce the size of (X)HTML files.

(4) Use server-side GZIP to compress JS/CSS files to reduce the size of the transferred files.

3. Control client cache through versioning.

How to update these cached files in time? Through a simple configuration, you can tell the browser in time by modifying the JS version that these files must be requested again and do not continue to use the data in the browser cache. There are several solutions:

(1) Manually change the file names of these JS.

(2) Manually change the paths of these JS.

(3) Relocate the JS path through URL Rewrite.

(4) Inform the page through a JS configuration on a high-response server which JS files should be linked to this page.

(5) The large version remains unchanged, the small version is continuously added, and will be updated uniformly after a certain period of time to efficiently utilize the cache.

4. Help the page lose weight.

5. Delete some dispensable content on the page.

Mainly refers to redundant spaces, tabs, blank lines, double quotes, single quotes, comments, etc.

6. Delete empty statements in the web page code.

For example:

<span style=&#39;font-family:宋体&#39;>你好<span lang=EN-US><o:p></o:p></span></span>

Obviously, the sentences after "Hello" have no effect, we can delete them.

7. Delete the default attributes of HTML.

HTML language has many default attributes, such as alignment, fonts, colors, etc., but web page production software will add these useless codes. For example: the align attribute defaults to left alignment, so we don’t need to write "align=left" when aligning to the left.

8. Optimize CSS.

For example: use abbreviated CSS.

Or:

<p class="decorated">1</p>
    <p class="decorated">2</p>
    <p class="decorated">3</p>
    <p class="decorated">4</p>

You can use p to include:

  <p class="decorated">
        <p>1</p>
        <p>2</p>
        <p>3</p>
        <p>4</p>
    </p>

9. Visibility is faster than Display.

10. Keep the case consistent for the same URL.

Internet Explorer’s buffer also treats uppercase and lowercase strings differently. Therefore, as a web developer, you must remember to keep the capitalization of URL strings for the same link consistent in different locations. Otherwise, different file backups of the same location will be stored in the browser's buffer, which will also increase the number of requests to download content from the same location.

11. Let the mark have a beginning and an end.

12. Do not stuff the entire page content into a Table.

Because the Table will be displayed after all the contents are added, if some contents are inaccessible, it will delay the access speed of the entire page. The correct approach is to divide the content into several Tables with the same format, rather than cramming them all into one Table.

13. Use iframe to nest another page.

If you need to insert advertising code and don’t want to affect the speed, then using iframe is the most suitable. The display of the page will not be affected by the delay of the advertising code.

14. Move JavaScript to the end of the HTMl file.

Because JavaScript will block the display of subsequent pages during processing, and will also block HTML requests.

15. The knowledge of friendly links.

(1) Only make text links. Making text links will not delay the speed of the web page.

(2) Put all links into a separate paging area, and then link to the page on the home page.

(3) If the friendly link must appear on the homepage, then please put the entire Table where the link is located at the bottom of the page, because the page is displayed line by line from top to bottom.

(4) Download the logo image of the friendly link first and then upload it to your own web space.

16. Image optimization.

(1) Reduce the number of pictures: remove unnecessary pictures.

(2) Reduce image quality: For pictures in JPG format, pictures that are reduced by 5% do not seem to have changed much, but the file size changes significantly.

(3) Use the appropriate format: JPG is generally used to display photography works of landscapes, people, and artistic photos, and is sometimes used in computer screenshots; GIF provides fewer colors and can be used in some applications that require color. Low-profile places, such as website logos, buttons, emoticons, etc.; PNG format can provide a transparent background and is generally used on web pages that require transparent background display or have higher image quality requirements.

17. Add a slash after the URL.

When the server receives such an address, it takes time to determine the file type of this address. If 220 is a directory, you might as well add an extra slash after the URL, so that the server will know at a glance that it wants to access the index or default file in the directory, thus saving time.

18. Indicate height and width.

If there is no setting, the browser will calculate the size while downloading the image. If there are many images, the browser will need to constantly adjust the page, which not only affects the speed, but also affects the browsing experience. When the browser knows the height and width, even if the image cannot be displayed, it will make room for the image on the page and continue to load the following content. As a result, it loads faster and the browsing experience is better.

The above is the detailed content of Detailed explanation of examples of html page optimization. For more information, please follow other related articles on the PHP Chinese website!

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
HTML超文本标记语言--超在那里?(文档分析)HTML超文本标记语言--超在那里?(文档分析)Aug 02, 2022 pm 06:04 PM

本篇文章带大家了解一下HTML(超文本标记语言),介绍一下HTML的本质,HTML文档的结构、HTML文档的基本标签和图像标签、列表、表格标签、媒体元素、表单,希望对大家有所帮助!

html和css算编程语言吗html和css算编程语言吗Sep 21, 2022 pm 04:09 PM

不算。html是一种用来告知浏览器如何组织页面的标记语言,而CSS是一种用来表现HTML或XML等文件样式的样式设计语言;html和css不具备很强的逻辑性和流程控制功能,缺乏灵活性,且html和css不能按照人类的设计对一件工作进行重复的循环,直至得到让人类满意的答案。

web前端笔试题库之HTML篇web前端笔试题库之HTML篇Apr 21, 2022 am 11:56 AM

总结了一些web前端面试(笔试)题分享给大家,本篇文章就先给大家分享HTML部分的笔试题(附答案),大家可以自己做做,看看能答对几个!

HTML5中画布标签是什么HTML5中画布标签是什么May 18, 2022 pm 04:55 PM

HTML5中画布标签是“<canvas>”。canvas标签用于图形的绘制,它只是一个矩形的图形容器,绘制图形必须通过脚本(通常是JavaScript)来完成;开发者可利用多种js方法来在canvas中绘制路径、盒、圆、字符以及添加图像等。

总结HTML中a标签的使用方法及跳转方式总结HTML中a标签的使用方法及跳转方式Aug 05, 2022 am 09:18 AM

本文给大家总结介绍a标签使用方法和跳转方式,希望对大家有所帮助!

html中document是什么html中document是什么Jun 17, 2022 pm 04:18 PM

在html中,document是文档对象的意思,代表浏览器窗口的文档;document对象是window对象的子对象,所以可通过“window.document”属性对其进行访问,每个载入浏览器的HTML文档都会成为Document对象。

html5废弃了哪个列表标签html5废弃了哪个列表标签Jun 01, 2022 pm 06:32 PM

html5废弃了dir列表标签。dir标签被用来定义目录列表,一般和li标签配合使用,在dir标签对中通过li标签来设置列表项,语法“<dir><li>列表项值</li>...</dir>”。HTML5已经不支持dir,可使用ul标签取代。

Html5怎么取消td边框Html5怎么取消td边框May 18, 2022 pm 06:57 PM

3种取消方法:1、给td元素添加“border:none”无边框样式即可,语法“td{border:none}”。2、给td元素添加“border:0”样式,语法“td{border:0;}”,将td边框的宽度设置为0即可。3、给td元素添加“border:transparent”样式,语法“td{border:transparent;}”,将td边框的颜色设置为透明即可。

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

Repo: How To Revive Teammates
1 months agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
1 months agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

VSCode Windows 64-bit Download

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.