How to better reduce page loading time, 19 methods are provided below, for reference only, interested friends can take a look.
1. The number of repeated HTTP requests should be reduced as much as possible
(1) Reduce the number of calls to other pages and files.
(2) Sprite diagram
2. Place the definition of css style in the header of the file
This setting is suitable for users with slow network or large web page content. The situation is more favorable, and the format information can be maintained while the web page is gradually rendered, without affecting the beauty of the web page.
3. Put Javascript script at the end of the file
4. Compress Javascript and CSS code
5. Use CDN (Content Delivery Network) network acceleration
There are many companies doing CDN acceleration business in China. To put it simply, it is to spread your pictures and videos to places that the CDN network can reach, so that users can download these files nearby when they visit, thereby achieving the purpose of speeding up the network. Doing this , while reducing the load on your own website.
6. Enable gzip compression function on the server
After compressing the files to be transferred and then transferring them to the client and then decompressing them, the amount of data transmitted over the network will be greatly reduced. Apache and Nginx on the server can be enabled directly. You can also use code to directly set the transmission file header and add gzip settings. You can also set it directly from the load balancing device. However, it should be noted that this setting will slightly increase the load on the server. Websites whose server performance is not very good should be carefully considered.
7. Ajax uses cache calling
Ajax calls all use cache calling, and are generally implemented using additional feature parameters. Pay attention to
{VERHASH} is the characteristic parameter. If this parameter does not change, the cache file will be used. If it changes, the new file will be downloaded again or the information will be updated.
8. Try to use the GET method for Ajax calls
When actually using XMLHttpRequest, if the POST method is used, two HTTP requests will occur, while only one HTTP request will occur using the GET method. . If you use the GET method instead, HTTP requests are reduced by 50%!
9. Develop good development and maintenance habits and try to avoid repeated calls to scripts
10. Reduce the use of iframes and try not to use them if unnecessary
11. Reasonable Using Flush
After the client sends browsing requests, the server generally takes 200-500ms to process these requests. During this period, the client browser is in a waiting state. If you want to reduce the user's waiting time, you can Use flush at the appropriate location to push ready content to the client. This is easy to implement in PHP. For example:
<!-- css, js --> </head> <?php flush();?> <body> ... <!-- content -->
12. Avoid using 301 and 302 redirection
When the browser, When a "crawler" sent by a proxy or search engine makes a request for a page or URL, the web server where the calling page or URL is located will check a file named .htaccess. This file contains instructions on how to handle specific requests and plays a key role in security. Users can modify this file to notify the browser, agent or "crawler" whether the called page is temporarily removed (302 redirect) or permanently removed (301 redirect). We can also implement 301/302 permanent redirects through web hosting services instead of .htaccess' files.
13. Optimize image files
Optimize image files and reduce their size, especially thumbnails. Be sure to generate thumbnails according to size and then call them. Do not use the resize method on the web page. Although the image you see in this way is smaller in appearance, the amount of data loaded has not been reduced at all.
Ordinary images and icons should also be compressed as much as possible. This can be achieved by saving web images, reducing the number of colors, etc.
14. When the page content is large enough, it can be displayed in paging, or loaded after page turning like Taobao.
15. Use multiple domain names to load multiple files and pictures in a web page
Some data indicate that during the web page loading process, IE loads the same domain name at the same time. The maximum number of parallel HTTP requests is 2. If the number of files that a web page needs to load exceeds 2 (usually far more than...), to speed up web page access, it is best to distribute the files to multiple domain names, such as the 19th floor, Its js files use independent domain names. It is said that Baidu has more than 20 image servers.
16. css and javascript should be called externally
If the content of css and js is relatively large, try not to write it into the same page. It is more appropriate to load it externally, because browsing The server itself will cache css and js files.
17. Reduce DCOM elements as much as possible
Reduce the number of various elements in the web page as much as possible. For example,
The above is the detailed content of How to better reduce page loading time. For more information, please follow other related articles on the PHP Chinese website!

The future of HTML will develop in a more semantic, functional and modular direction. 1) Semanticization will make the tag describe the content more clearly, improving SEO and barrier-free access. 2) Functionalization will introduce new elements and attributes to meet user needs. 3) Modularity will support component development and improve code reusability.

HTMLattributesarecrucialinwebdevelopmentforcontrollingbehavior,appearance,andfunctionality.Theyenhanceinteractivity,accessibility,andSEO.Forexample,thesrcattributeintagsimpactsSEO,whileonclickintagsaddsinteractivity.Touseattributeseffectively:1)Usese

The alt attribute is an important part of the tag in HTML and is used to provide alternative text for images. 1. When the image cannot be loaded, the text in the alt attribute will be displayed to improve the user experience. 2. Screen readers use the alt attribute to help visually impaired users understand the content of the picture. 3. Search engines index text in the alt attribute to improve the SEO ranking of web pages.

The roles of HTML, CSS and JavaScript in web development are: 1. HTML is used to build web page structure; 2. CSS is used to beautify the appearance of web pages; 3. JavaScript is used to achieve dynamic interaction. Through tags, styles and scripts, these three together build the core functions of modern web pages.

Setting the lang attributes of a tag is a key step in optimizing web accessibility and SEO. 1) Set the lang attribute in the tag, such as. 2) In multilingual content, set lang attributes for different language parts, such as. 3) Use language codes that comply with ISO639-1 standards, such as "en", "fr", "zh", etc. Correctly setting the lang attribute can improve the accessibility of web pages and search engine rankings.

HTMLattributesareessentialforenhancingwebelements'functionalityandappearance.Theyaddinformationtodefinebehavior,appearance,andinteraction,makingwebsitesinteractive,responsive,andvisuallyappealing.Attributeslikesrc,href,class,type,anddisabledtransform

TocreatealistinHTML,useforunorderedlistsandfororderedlists:1)Forunorderedlists,wrapitemsinanduseforeachitem,renderingasabulletedlist.2)Fororderedlists,useandfornumberedlists,customizablewiththetypeattributefordifferentnumberingstyles.

HTML is used to build websites with clear structure. 1) Use tags such as, and define the website structure. 2) Examples show the structure of blogs and e-commerce websites. 3) Avoid common mistakes such as incorrect label nesting. 4) Optimize performance by reducing HTTP requests and using semantic tags.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Dreamweaver Mac version
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function

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.

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.
