简体   繁体   中英

Conflicting of standards about the MIME type for javascripts?

RFC4329 and IANA says it's application/javascript , and text/javascript is obsolete. However, HTML standard (by WHATWG ) says servers should use text/javascript rather than other obsolete types.

Why is there such a difference? What is the correct MIME type we should use for javascripts? Does it mean that web servers should use text/javascript for scripts meant to be run by the browsers and use application/javascript in other cases (eg for a js file to be downloaded)?

In most real-world cases there is no difference.

One difference with any text/* mimetype vs. application/* mimetypes is that implementations may automatically convert the character encoding depending on the Accept-Charset header without knowing anything else about the text format.

I haven't seen many real world cases where this happens. I believe that most places now use text/javascript . I assume that this is the case because application/javascript simply hasn't caught on that much.

There's a lot of conjecture here without sources, so take it with a grain of salt. I hope it's helpful.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM