當(dāng)前位置:首頁 > IT技術(shù) > 移動(dòng)平臺(tái) > 正文

js mine 類型javascript----text/javascript,application/javascript, and appliation/x-javascript
2021-08-07 19:06:41

這兩天使用iewatch觀察google的網(wǎng)站的時(shí)候,發(fā)現(xiàn)學(xué)到j(luò)s文件的mime類型為text/javascript,而今天在qq的網(wǎng)站上,使用iewatch發(fā)現(xiàn),有時(shí)用text/javascript的,也有使用application/javascript的還有使用appliation/x-javascript的,所有就不太知道這三個(gè)mime 類型有什么區(qū)別,在google上一搜:

The traditional MIME type for JavaScript programs is
"text/javascript". Another type that has been used is
"application/x-javascript" (the "x" prefix indicates that it is an
experimental, nonstandard type). RFC 4329 standardized the
"text/javascript" type because it is in common use. However, because
JavaScript programs are not really text documents, it marks this type
as obsolete and recommends "application/javascript" (without the "x-")
instead. At the time of this writing, "application/javascript" is not
well supported, however. That might be the reason why
"application/x-javascript" is used by a lot of webpages.

大致意思是:傳統(tǒng)的javascript程序的MIME類型是“text/javascript”,其他使用的還有"application/x-javascript"(x前綴表示這是實(shí)驗(yàn)性的,不是標(biāo)準(zhǔn)的類型),RFC4329規(guī)定了“text/javascript”類型,因?yàn)樗毡楸皇褂?。然而,javascript程序并不是真正的文本文件,這就表示這個(gè)類型已經(jīng)意味著過時(shí)了,而推薦使用"application/javascript"(去除x前綴)。然而,在寫程序的時(shí)候,"application/javascript"沒有很好的支持。這也行就是"application/x-javascript"被使用在很多網(wǎng)頁中的原因。


作者:高級(jí)測(cè)試開發(fā)網(wǎng)
本文版權(quán)歸作者所有,歡迎轉(zhuǎn)載,但未經(jīng)作者同意必須保留此段聲明,且在文章頁面明顯位置給出原文連接,否則保留追究法律責(zé)任的權(quán)利。
?
?
?
?

本文摘自 :https://blog.51cto.com/u

開通會(huì)員,享受整站包年服務(wù)立即開通 >