Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
61
rated 0 times [  62] [ 1]  / answers: 1 / hits: 28614  / 13 Years ago, wed, may 25, 2011, 12:00:00

Possible Duplicate:

When serving JavaScript files, is it better to use the application/javascript or application/x-javascript






what is difference between text/javascript and application/javascript?



As IE will completely ignore the script tag if you have set type attribute to application/javascript.



But what is the main difference and in which case we need to use the particular.


More From » javascript

 Answers
10

text/javascript was introduced when the web was young and people hadn't thought things through.



Then people thought things through, and decided that text/* should be reserved for things designed to be human readable (which is why some XML is text/xml and other XML is application/xml). JavaScript is not human readable, so text/javascript was deprecated and application/javascript was introduced to replace it.



Years later, some browsers still haven't caught up.



You can configure your server to always serve application/javascript in the HTTP headers; browsers that don't support it also pay no attention to the actual content-type.



For the time being, if you are writing HTML 4 or XHTML 1, specify text/javascript in the type attribute for the sake of backwards compatibility. If you are writing HTML 5, then omit the type attribute (as it is now optional).


[#92060] Tuesday, May 24, 2011, 13 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
myrap

Total Points: 407
Total Questions: 105
Total Answers: 109

Location: Cambodia
Member since Thu, Oct 7, 2021
3 Years ago
myrap questions
Tue, Feb 8, 22, 00:00, 2 Years ago
Wed, Jan 15, 20, 00:00, 4 Years ago
Thu, Oct 24, 19, 00:00, 5 Years ago
Thu, Oct 3, 19, 00:00, 5 Years ago
Mon, Aug 12, 19, 00:00, 5 Years ago
;