HTML and CSS Reference
In-Depth Information
async
(
async="async"
in XHTML)
Not in HTML 4.01
. Indicates an external script should be executed asynchronously, as
soon as it is available.
charset="
character set
character set
"
Indicates the character encoding of an external script document (it is not relevant to the
content of the
script
element).
crossorigin="anonymous|use-credentials"
Not in HTML 4.01
. For sites that allow scripts from other domains, this attribute determ-
ines whether error information for scripts from other origins will be exposed.
defer
(
defer="defer"
in XHTML)
Indicates to the user agent that an external script should be executed once the page is fin-
ished parsing.
src="
URL
URL
"
Provides the location of an external script.
type="
content-type
content-type
"
Required in HTML 4.01. Optional in HTML5 if using JavaScript
. Specifies the
scripting language used for the current script. The value is a content type, most often
text/javascript
.
xml:space="preserve"
XHTML only
. Instructs XML processors to preserve the whitespace in the element.
Examples
<script>
var foo = 52;
alert(foo);