defer Attribute


 

Where to use the defer Attribute


Description

The defer attribute is a Boolean attribute which may be specified on a script element to indicate to the user agent that the script does not produce any document content and that page may finish loading before the script is executed.

This attribute has only partial support among user agents but, if you accept that it is merely a hint to the user agent and do not rely upon it, there's little harm in including it. If you need to use the DOM, for example, you should not assume that your document will have loaded before executing your deferred script. Use a JavaScript window.onload handler, for example, to make sure that you don't try to access the DOM before it's available.

See also the onload attribute.


Page Footer & Copyright

Copyright © Sally Maughan 2005-2009 (Page last updated on 16 May 2009)

*Valid XHTML 1.1 - hosted by *Openstrike

Content based on the W3C Working Draft: *XHTML 1.1 and Recommendation: *XHTML Modularisation 1.1.

W3C, XHTML, XML, HTML, CSS and MathML are *Trademarks of the W3C (*MIT, *ERCIM, *Keio) with which the site's author has no connection.


Up, Next & Previous Links

Your Location

Home > XHTML 1.1 Home > XHTML 1.1 Indexes > Attribute Index (XHTML 1.1) > defer Attribute (XHTML 1.1)