HTML and CSS Reference
In-Depth Information
For example, either of the following expressions would return the font size of the first
paragraph under Internet Explorer:
Unlike the getComputedStyle() method, the currentStyle() method returns val-
ues in either absolute or relative units and also works with shortcut properties.
Problem Solving: Reducing Network Lag with Parallel Downloads
The biggest cause of slow Web pages is network lag. Most typical Web pages spend 80% to
90% of their load time waiting for the network to respond. One way to reduce network lag
is to make the browser download as much content as possible in parallel (simultaneously)
rather than serially (one at a time). Inline image files are one example of a file type that
browsers download in parallel rather than serially. External script files are not. Browsers, in
fact, halt the subsequent downloading of any other external file until a script file has been
completely downloaded. Therefore, one way to reduce network lag is to combine multiple
external script files into one file.
Because script files are downloaded serially, you should list links to other external files
before the script files in your code. For example, external style sheet files should be listed
before external script files. When style sheets are listed in this fashion, browsers retrieve
them even as they are downloading the script files. However, if you list the script files first,
browsers do not download the style sheets until they have finished downloading the scripts.
Even JavaScript code that is embedded within the Web document blocks subsequent
downloads until it has been read and parsed by the browser. Therefore, you always
should place links to external style sheets at the top of your document before embedded
scripts. This also enables the browser to progressively build the page as it interprets the
style sheet code. Therefore, to attain faster download times, the general rule of thumb is to
place the links to your script files last in your code.
Session 14.3 Quick Check
1. Provide the commands to create an inline image node named imgObj , and then
insert it before the first child of the first article element in a document.
2. Provide a command to hide the display of the imgObj node in the document.
3. What are preferred and alternate style sheets? What is a persistent style sheet?
4. What is the object reference to the third style sheet loaded by the browser for the
current document?
5. Provide a JavaScript command to disable the third style sheet.
6. Provide an expression to reference the second style rule from the document's third
style sheet.
7. Provide commands to access the calculated styles for the document's first
article element. Store the style declarations in a variable named articleStyles .
8. Provide a command to view the calculated width, in pixels, of the document's first
article element using the articleStyles variable from the previous question.
9. You want to determine the font size of the text in the document's first paragraph.
Explain why the following expression may be inadequate for the task:
Search WWH ::

Custom Search