Developer on Alibaba Coud: Build your first app with APIs, SDKs, and tutorials on the Alibaba Cloud. Read more ＞
Loops Control Multiple animations
When it comes to making animation, of course the use of the timer. The usual approach is to use window.settimeout to constantly position the elements on the page. However, if there are more than one animation on the page to display, is it necessary to set more than one timer? The answer is no!. The reason is simple: the timer function consumes a lot of valuable system resources. But we can still control multiple animations on the page, and the trick is to use a loop. Control the position of the animation according to the variable values in the loop, using only one window.settimeout () function call in the entire loop.
Visibility faster than display
There are 2 ways to do this by making the picture come and go: using the CSS visibility attribute or display property. For absolute position elements, diaplay and visibility have the same effect. The difference is that elements that are set to Display:none will no longer occupy the space of the document flow, while elements set to Visibility:hidden remain in place.
However, if you want to handle elements of absolute position, it is quicker to use visibility.
One important tip for writing a DHTML Web page is to start small. When you first write a DHTML page, be sure not to try to use all of the DHTML features you've learned in the page. You can use only one single new feature at a time, and carefully observe the resulting changes. If you find that performance has fallen, you can quickly find out why.
The defer of the script
Defer is one of the "unsung heroes" of the Scripting power. You may never have used it, but after reading this introduction, believe you can not live without it. It tells the browser that the script section contains code that does not need to be executed immediately, and that it is used in conjunction with the SRC attribute to enable the scripts to be downloaded in the background, and the contents of the foreground are displayed to the user normally.
Finally, please note two points:
1, do not call the document.write command in the defer script segment, because document.write will produce a direct output effect.
2. Also, do not include any global variables or functions that are to be used for immediate execution of scripts in the defer script segment.
Keep the case consistency of the same URL
We all know that UNIX servers are case-sensitive, but do you know that Internet Explorer's buffers also treat case strings differently. Therefore, as a web developer, be sure to remember that the URL string that keeps the same link is case-sensitive in different locations. Otherwise, a different file backup in the same location is stored in the browser's buffer, and the number of requests to download the contents of the same location is increased. These all undoubtedly reduce the efficiency of Web Access. So remember: URLs in the same location, keep the case consistency of the URL strings in different pages.
Let the mark finish
When you write or view other people's HTML code, we must all encounter the situation of tagged halves. Like what:
<P> Halves Mark Example
<LI> a second
<LI> a third
Obviously, there are three </LI> end tags missing from the above code. But that doesn't prevent it from being executed properly. In HTML, there are a few such tags, such as frame, IMG, and P.
But please do not be lazy, please write the closing tag complete, this not only makes the HTML code format specification, but also can speed up the display speed of the page. Because Internet Explorer will not take time to judge and calculate where paragraphs or list items end.
<P> Manage Mark Example </P>
<LI> First </LI>
<LI> Second </LI>
<LI> a third </LI>
OK, here's a list of 10 techniques for speeding up HTML pages, and it's simple to describe them, but you can write faster, better programs only if you really understand and grasp the nature of it and extrapolate.
This article is an English version of an article which is originally in the Chinese language on aliyun.com and is provided for information purposes only. This website makes no representation or warranty of any kind, either expressed or implied, as to the accuracy, completeness ownership or
reliability of the article or any translations thereof. If you have any concerns or complaints relating to the article, please send an email, providing a detailed description of the concern or
complaint, to email@example.com. A staff member will contact you within 5 working days. Once verified, infringing content will be removed immediately.
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:
and provide relevant evidence. A staff member will contact you within 5 working days.