스크립트 태그의 유형 속성에 대한 JavaScript Mime 유형은 무엇입니까? [복제하다
-
06-07-2019 - |
문제
이 질문은 이미 여기에 답이 있습니다.
이것은 몸짓 광대극 JavaScript의 유형?
보다 구체적으로, 스크립트 태그의 "타입"속성에 넣을 옳은 것은 무엇입니까? application/x-javascript
그리고 text/javascript
주요 경쟁자 인 것 같습니다.
해결책
이것은 일반적인 실수입니다. JavaScript의 MIME 유형은 수년 동안 표준화되지 않았습니다. 지금이야 공무상: "응용 프로그램/JavaScript".
여기서 진짜 키커는 대부분의 브라우저가 적어도 스크립트 태그의 경우에는 해당 속성을 사용하지 않는다는 것입니다. 그들은 실제로 패킷 내부를 들여다보고 스스로 유형을 결정합니다.
결론은 유형 = "text/javaScript"가 JavaScript에 관한 한 아무것도하지 않지만 둘 다의 사양의 일부입니다. HTML 4 그리고 XHTML 1.0.
다른 팁
멀리서 이것은 주제에서 내가 찾은 첫 번째 페이지입니다.
내 집단 연구는 다음과 같습니다.
text/javascript
Keparo가 언급 한 바와 같이 유효성 검사를 원한다면 HTML4 및 XHTML1에서 사용해야합니다. 브라우저는 무시하지만.application/javascript
모든 사람이 동의하고 모든 것이 따라 잡을 때 새로운 공식 Mime 유형이 될 것으로 예상됩니다.application/x-javascript
(X 비공식 의미)는 JavaScript의 현재 서버 측 MIME 참조입니다.- 모든 사람들은 평소와 같이 Microsoft가 문제를 더 혼란스럽게 만들기 위해 완전히 다른 일을하기로 결정할 것이라고 기대합니다.
요약 : 지금은 HTML/XHTML이 MSIE에서 작동하고 W3C로 검증하려면 선언합니다. type="text/javascript"
. 웹 서버가 JavaScript를 의미한다는 것을 알기를 원한다면 application/x-javascript
.
스크립트 태그에서 텍스트/JavaScript를 사용합니다. 어쨌든 이것은 HTML 4.0 사양에 나타납니다.
http://www.w3.org/tr/rec-html40/interact/scripts.html
편집] 재미있는 방법 RFC Application/JavaScript에서 표준화 된 것은 2 년이지만 Text/JavaScript는 여전히 더 일반적입니다. 이것은 표준에 대한 또 다른 맞춤형 승리의 사례입니까? 그것은 또한 나타납니다 html5.
JavaScript Mime 유형을 정의하는 공식 RFC는 RFC4329.
7. JavaScript Media Types 7.1. text/javascript (obsolete) Type name: text Subtype name: javascript Required parameters: none Optional parameters: charset, see section 4.1. Encoding considerations: The same as the considerations in section 3.1 of [RFC3023]. Security considerations: See section 5. Interoperability considerations: None, except as noted in other sections of this document. Published specification: [JS15] Applications which use this media type: Script interpreters as discussed in this document. Additional information: Magic number(s): n/a File extension(s): .js Macintosh File Type Code(s): TEXT Person & email address to contact for further information: See Author's Address section. Intended usage: OBSOLETE Restrictions on usage: n/a Author: See Author's Address section. Change controller: The IESG. 7.2. application/javascript Type name: application Subtype name: javascript Required parameters: none Optional parameters: charset, see section 4.1. Encoding considerations: The same as the considerations in section 3.2 of [RFC3023]. Security considerations: See section 5. Interoperability considerations: None, except as noted in other sections of this document. Published specification: [JS15] Applications which use this media type: Script interpreters as discussed in this document. Additional information: Magic number(s): n/a File extension(s): .js Macintosh File Type Code(s): TEXT Person & email address to contact for further information: See Author's Address section. Intended usage: COMMON Restrictions on usage: n/a Author: See Author's Address section. Change controller: The IESG.