Script typeProperties
Example
Get the MIME type of a script:
var x = document.getElementById("myScript").type
xThe output is:
text/javascript
Try it Yourself »
Definition and Usage
The type attribute sets or returns the value of the type attribute of a script.
The type attribute specifies the MIME type of a script.
The type attribute identifies the content between the <script> and </script> tags.
MIME types consist of two parts: a media type and a subtype. For JavaScript, the MIME type is "text/javascript".
Note:In HTML5, the type attribute is no longer required. The default value is "text/javascript".
Browser Support
![]()
![]()
![]()
![]()
![]()
All major browsers support the type attribute.
Syntax
Return the type attribute:
scriptObject.type
Set the type attribute:
scriptObject.type=MIME_type
Property Values
| Value | Description |
|---|---|
| MIME_type | Specifies the MIME type of a script. Some common values:
See alsoIANA MIME types, for a complete list of standard MIME types. |
Technical Details
| Return Value: | A string, representing the MIME type of the script. |
|---|
Related Articles
HTML Reference Manual:HTML <script> type Attribute
Other Extensions
Script Object