Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.2k views
in Technique[技术] by (71.8m points)

what is difference between text/javascript and application/javascript


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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).


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...