Home Backend Development PHP Tutorial WEB project optimization skills (must know)

WEB project optimization skills (must know)

Jul 29, 2016 am 09:03 AM
cookie css http nbsp

1. Minimize HTTP Requests Reduce HTTP requests
Pictures, css, script, flash, etc. will increase the number of http requests. Reducing the number of these elements can reduce the response time. Write multiple JS and CSS into one file if possible. It is also a bad practice to write images directly into the page. You should write them into CSS and use CSS sprites Use the background to position the small pictures after piecing them together.
  2. Use a Content Delivery Network Using CDN technology
CDN is indeed a good thing, but the server provider generally charges a fee for this service.
  3.Add an Expires or a Cache-Control Header Set header file expiration or static cache
  The browser will use caching to reduce the number of http requests to speed up the page loading time. If the page header adds a very With a long expiration time, the browser will keep caching the elements in the page. However, if something on the page changes, the name will need to be changed, otherwise the client will not actively refresh. It depends on your own measurement~ This can be achieved by modifying the .htaccess file.
 4.Gzip Components Gzip Compression
Gzip format is a very common compression technology. Almost all browsers have the ability to decompress the Gzip format, and the compression ratio it can compress is very large. The general compression rate 85%
  5. Put Stylesheets at the Top Put CSS at the top
 so that visitors can see the complete style of the website as early as possible.
  6. Put Scripts at the Bottom Put JS at the bottom
  After the website is rendered, you can set the functions. Of course, these JS must not affect the content performance during your loading process.
  7.Avoid CSS Expressions
  CSS expressions are terrible. This thing that is only supported by IE requires a very large amount of calculations when executed. It will be recalculated every time you move the mouse.
  8.Make JavaScript and CSS External Link JS and CSS
  I talked about caching earlier. For some more common JS and CSS, we can use external links. For example, I use external links from Google. For the linked Jquery file, if my visitor has downloaded and cached this file when browsing other websites that use this external link file, then he does not need to download it when browsing my website! ~
  9.Reduce DNS Lookups Reduce DNS lookups
  It seems to be to reduce the website’s call of external resources. My Google analysis and picasa’s external link pictures are included in it.
  10.Minify JavaScript and CSS Reduce the size of JS and CSS
There are skills in writing JS and CSS. Use the least code to achieve the same function, reduce white space, enhance logic, and use abbreviations. Wait, of course there are many tools that can help you achieve this.
 11. Avoid Redirects Avoid redirects
 When writing the link, although "http://www.today-s-ooxx. com" and "http://www.today-s-ooxx. com/" only has one final "/" difference, but the results are different. The server needs to spend time redirecting the former to the latter and then jump. You need to pay attention to this. You can also use Alias ​​or mod_rewrite in Apache. Or use DirectorySlash to solve it.
  12. Remove Duplicate Scripts
 The browser will not recognize and ignore the code that is called repeatedly, but will calculate it again, which is of course a big waste. 13. Configure ETags Configure ETags
I don’t know what happened, anyway, I deleted it in . htaccess
  14. Make Ajax Cacheable Cache Ajax
Before the browser receives new data, the old data is cached, which can better improve efficiency
  15. Flush the Buffer Early Release the buffer as early as possible
  When the user makes a page request, the server The end needs to spend 200 to 500 milliseconds to assemble the HTML and write it between the head and the body to release the buffer. This way, the file header can be sent first and then the file content can be sent to improve efficiency
  16. Use GET. for AJAX Requests Use GET method to make AJAX requests
  The Get method only interacts with the server once (sending data), while Post requires two times (sending headers and then sending data).
 17. Post-load Components Delay Loading components
Load the necessary components first to initialize the page, and then load others, YUI Image Loader
is a good example.
  18. Preload components Preload components
Loading things that may be used later does not conflict with lazy loading. Its purpose is to provide a faster response to subsequent requests, see CSS on the Google homepage sprites application.
  19. Reduce the Number of DOM Elements Reduce the number of DOM elements
 Complex page structure means longer download and response time, more reasonable and efficient use of tags to structure the page, which is a good front-end Prerequisites.
  20. Split Components Across Domains
  Multiple sources of page components can increase your parallel downloads, but be careful not to have too many. More than 2-4 domain names will cause the above mentioned DNS lookup waste.
  21. Minimize the Number of iframes Reduce the number of iframes
 Need to use ifames more effectively.
iframe advantages: good for downloading slow third-party content such as ads, security sandbox, parallel download scripts
iframe disadvantages: even if it is empty, it will consume a lot of resources, will prevent the onload of the page, non-semantic
  22. No 404s Do not have 404 pages
  404 pages appear on the site itself (not search results). Meaningless 404 pages will affect the user experience and consume server resources.
  23. Reduce Cookie Size Reduce Cookie
  Cookies are exchanged through file headers between the server and the browser, reducing the cookie size as much as possible and setting a reasonable expiration time, which can greatly improve efficiency. .

The above introduces the WEB project optimization skills (must know), including the relevant content. I hope it will be helpful to friends who are interested in PHP tutorials.

Statement of this Website
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

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

Video Face Swap

Video Face Swap

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

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to use bootstrap in vue How to use bootstrap in vue Apr 07, 2025 pm 11:33 PM

Using Bootstrap in Vue.js is divided into five steps: Install Bootstrap. Import Bootstrap in main.js. Use the Bootstrap component directly in the template. Optional: Custom style. Optional: Use plug-ins.

The Roles of HTML, CSS, and JavaScript: Core Responsibilities The Roles of HTML, CSS, and JavaScript: Core Responsibilities Apr 08, 2025 pm 07:05 PM

HTML defines the web structure, CSS is responsible for style and layout, and JavaScript gives dynamic interaction. The three perform their duties in web development and jointly build a colorful website.

Understanding HTML, CSS, and JavaScript: A Beginner's Guide Understanding HTML, CSS, and JavaScript: A Beginner's Guide Apr 12, 2025 am 12:02 AM

WebdevelopmentreliesonHTML,CSS,andJavaScript:1)HTMLstructurescontent,2)CSSstylesit,and3)JavaScriptaddsinteractivity,formingthebasisofmodernwebexperiences.

How to write split lines on bootstrap How to write split lines on bootstrap Apr 07, 2025 pm 03:12 PM

There are two ways to create a Bootstrap split line: using the tag, which creates a horizontal split line. Use the CSS border property to create custom style split lines.

How to insert pictures on bootstrap How to insert pictures on bootstrap Apr 07, 2025 pm 03:30 PM

There are several ways to insert images in Bootstrap: insert images directly, using the HTML img tag. With the Bootstrap image component, you can provide responsive images and more styles. Set the image size, use the img-fluid class to make the image adaptable. Set the border, using the img-bordered class. Set the rounded corners and use the img-rounded class. Set the shadow, use the shadow class. Resize and position the image, using CSS style. Using the background image, use the background-image CSS property.

How to use bootstrap button How to use bootstrap button Apr 07, 2025 pm 03:09 PM

How to use the Bootstrap button? Introduce Bootstrap CSS to create button elements and add Bootstrap button class to add button text

How to set up the framework for bootstrap How to set up the framework for bootstrap Apr 07, 2025 pm 03:27 PM

To set up the Bootstrap framework, you need to follow these steps: 1. Reference the Bootstrap file via CDN; 2. Download and host the file on your own server; 3. Include the Bootstrap file in HTML; 4. Compile Sass/Less as needed; 5. Import a custom file (optional). Once setup is complete, you can use Bootstrap's grid systems, components, and styles to create responsive websites and applications.

How to resize bootstrap How to resize bootstrap Apr 07, 2025 pm 03:18 PM

To adjust the size of elements in Bootstrap, you can use the dimension class, which includes: adjusting width: .col-, .w-, .mw-adjust height: .h-, .min-h-, .max-h-

See all articles