defer attribute (script)
3.5 | ||||
Sets whether the script is going to generate any document content.
If set to true, then the browser no need to wait for the script to load. The browser will load the script in the background while continuing to process the page.
Note that the defer attribute is supported in Firefox from version 3.5 and it is not supported for embedded script blocks, only for external script files.
See the examples below.
JavaScript page for this attribute: defer. You can find other example(s) there. |
Possible values:
Boolean that indicates the status of the script element.
One of the following values:
Default. Browser must wait for the script to load before starts processing the page. | |||||||
Browser no need to wait for the script to load before starts processing the page. |
Default: false.
Example HTML code 1:
This example illustrates the use of the defer attribute for embedded script blocks. This example only works in Internet Explorer, Firefox does not support the defer attribute for embedded script blocks:
|
||||
<head> <script type="text/javascript" defer="true"> alert ("This script block will be executed after content rendering time"); </script> <script type="text/javascript"> alert ("This script block will be executed during content rendering time"); </script> </head> |
||||
|
||||
Did you find this example helpful?
|
Example HTML code 2:
This example is similar to the previous one, but it works both in Internet Explorer and Firefox (from version 3.5) because it uses the defer attribute for external script files:
|
|||||||
<head> <script type="text/javascript" src="after.js" defer="true"></script> <script type="text/javascript" src="during.js"></script> </head> |
|||||||
|
|||||||
Did you find this example helpful?
|
Supported by tags:
Related pages:
External links:
User Contributed Comments