Website weight loss and code optimization record sharing

Source: Internet
Author: User

Intermediary transaction http://www.aliyun.com/zixun/aggregation/6858.html ">seo diagnose Taobao guest cloud host technology Hall

I just on the line last week Taobao type of small station, although one weeks, until now has not improved, but I still have the confidence to do it well, and I think as a webmaster, patience this thing is indeed necessary. Or you can never do a good station. This station is developed with an internationally renowned framework of PHP, the YII framework, and the benefits of Yii are quick and easy, and it is true. It has its own jquery and its UI class library, which is very convenient to use.

Let's start with the first question:

As a type of shopping site, the biggest drawback is that too many pictures caused the page to load slowly. Believed to have done this kind of station stationmaster all has this kind of feeling. In fact, there are many solutions to this problem, I am using the method of delaying the loading of pictures. Using a JQuery plug-in jquery.lazyload, this plugin is really good, it achieved a priority to display the browser visual area of the picture, delay loading the invisible area of the picture.

The idea is very practical: first of all, because do not need to load all the pictures at the same time, thus speeding up the visual area of the picture loading speed, and then is able to effectively reduce the flow, of course, if it is Taobao guest class web site calls Taobao website Pictures, this is not required their own traffic, but the first advantage, Is enough for us to make good use of it. Perhaps you would say, this is not a site to lose weight. In fact, I feel like this to reduce unnecessary traffic to the site, is to lose weight, because the ultimate goal of weight loss is two points: speed up the Web site operation, reduce unnecessary traffic.

Let me say the second question:

There is a commodity in my station, and the first layer shows the large category, and then links the large category to the subclass of this category. In the beginning, I went directly to the next page with a link to display the subclass, but then I used the jquery UI dialog method to display the subcategories because I thought it would be more effective and the user experience better. Of course, I still keep a link, so that when users disable JS, you can still access the list of subcategories.

So now the problem is, the jquery UI is really cool, but at the same time, as we all know, the jquery UI is huge! So, every time I visit my page of this kind of purpose, I feel not very fluent, this is the main purpose of my website to lose weight. In fact, the jquery UI can be customized to download, you can only tick the features you use, other do not tick, so download the file will be a lot smaller. The function I'm using now is actually a Dialog, plus the required core and two multiplying. So I customized a copy, the download completed after the original file. The original file is about 190K, customized after the 35K. Lost more than 140 K at a draught. Don't underestimate this 140K, if visit this page 100,000 times, it is equal to me to save 1G much traffic. Isn't this data exciting enough? Moreover, it is not only the benefits of saving traffic, less load 140K of files, you can make the page's access speed to improve a lot.

Having done all this, I still feel not fast enough to achieve the results I expected. It seems that the problem is not only appear in the JS file, so continue to troubleshoot the code. Later found that I Dialog inside the content is actually in the current page to get out, but it display:none, temporarily do not show, and so triggered the Dialog.open event, it will be displayed. So obviously the problem is here. Imagine if I had 50 large categories of eyes, now I only show these 50 categories of target in the current page, MySQL query only need 1 times to get out, if I am on the current page of these 50 categories under the subclass is also all get out, then will need to 1+50 query. This greatly reduces the execution efficiency of the program, and the link of this display:none state, to SEO only bad not benefit. Finally, I intend to use Ajax to invoke the child class destination data, have access to the need to give the data, do not need to execute so many times database query, greatly improve performance, but also reduce unnecessary code. Reasonable use of Ajax, it will certainly bring us unexpected harvest!

After the change, the test, this class purpose page loading speed has been as fast as other pages! Excited, unavoidably want to A5 to share with you, hope for everyone useful. Finally put my web site attached: http://www.wg580.net can go to test. Hope that we have a lot of support, thank you!

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.