In a lot of codes I’ve been seeing this, so that’s why I asked.
<script type=“text/javascript”>
</script>
In a lot of codes I’ve been seeing this, so that’s why I asked.
<script type=“text/javascript”>
</script>
Dynamic script such as text/javascript.
Means what?
<script type=“text/javascript”>
<script>
What’s the difference?
When do you use one and not the other?
https://en.oxforddictionaries.com/definition/dynamic
From the article linked:
This attribute indicates the type of script represented. The value of this attribute will be in one of the following categories:
- Omitted or a JavaScript MIME type: For HTML5-compliant browsers this indicates the script is JavaScript. HTML5 specification urges authors to omit the attribute rather than provide a redundant MIME type. In earlier browsers, this identified the scripting language of the embedded or imported (via the src attribute) code. JavaScript MIME types are listed in the specification.
The attribute was required in earlier versions of HTML, but can be omitted for JavaScript in HTML5. It’s assumed that the script is JS, unless otherwise specified.
Thank you, that was helpful.
Did you attempt to search for this information yourself before posting to the forums? Everyone here volunteers their time to help people who are genuinely stuck, but please keep in mind we’re not a free ‘google-it-for-you’ service.
Many years ago (decades now, back in the browser war days) there were more than one “flavor” of JavaScript.
At the time, depending on what kind of code it was, the syntax was like
<script language="javascript" ... >
<script language="jscript" ... >
<script language="vbscript" ... >
It was decided that a better approach would be to indicate the mime type and so the language attribute was phased out and the type attribute was introduced.
* see under “Deprecated” in the linked MDN page
Since that time, JavaScript has pretty much taken the field and is the de facto browser scripting language. So unless you are writing pages that are not HTML5 or are not using JavaScript, you no longer need the type attribute.
You may wonder, “what about jQuery?”. jQuery is not a different language, it is an implementation of JavaScript.
This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.