I have found myself including more and more external JS files from CDN sites and such. I always see that some sites include the MIME type when you copy the HTML code with the <script>
tag and some don't. What is the importance of including the MIME type? Are there browsers that won't support scripts without the MIME type?
Also I've heard that the "official" MIME type for JavaScript is application/javascript
but it seems like everyone uses text/javascript
. What are the implications of using either one?
It's actually not necessary in HTML5 based websites. If you're using the HTML5 doctype of <!DOCTYPE html>
then it's not necessary to include a specified type seeing as it's the default now.
With the advent of HTML5, all you need for your script tags is <script src="myScript.js"></script>
. If you're interested in more about the differences between application/javascript
and text/javascript
then check out this post.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With