Tuesday, May 17, 2022

[FIXED] What is an appropriate content-type header for JavaScript files?

Issue

I am delivering a JS response from a PHP file. When setting the Content-Type header which value should I use, application/javascript or text/javascript?

What’s the difference between the two?


Solution

According to the IANA Registered MIME media type list, JS has two registered MIME types; the obsolete text/javascript and the now official application/javascript.

Thus, use application/javascript.



Answered By - You
Answer Checked By - Timothy Miller (PHPFixing Admin)

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.