What is an appropriate content-type header for JavaScript files

0 votes
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?
Jul 7, 2020 in Java-Script by kartik
• 37,510 points
2,326 views

1 answer to this question.

0 votes

Hello @kartik,

JS has two registered MIME types:

 The obsolete text/javascript and the now official application/javascript.

Thus, use application/javascript. 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.

Hope it helps!!

Thank You!!

answered Jul 7, 2020 by Niroj
• 82,880 points

Related Questions In Java-Script

0 votes
1 answer

Which is best window.location (JS) vs header() (PHP) for redirection?

Hello @kartik, It depends on how and when ...READ MORE

answered Jul 7, 2020 in Java-Script by Niroj
• 82,880 points
8,128 views
0 votes
1 answer

How do I test for an empty JavaScript object?

Hello @kartik, Try this: var obj = {}; return Object.keys(obj).length; Hope ...READ MORE

answered Aug 28, 2020 in Java-Script by Niroj
• 82,880 points
386 views
0 votes
1 answer

What is the “hasClass” function with plain JavaScript?

Hello @Kartik, Simply use classList.contains(): if (document.body.classList.contains('thatClass')) { ...READ MORE

answered Sep 2, 2020 in Java-Script by Niroj
• 82,880 points
835 views
0 votes
1 answer

How can I determine the type of an HTML element in JavaScript?

Hello @kartik, nodeName is the attribute you are looking ...READ MORE

answered Oct 8, 2020 in Java-Script by Niroj
• 82,880 points
1,878 views
0 votes
1 answer

How can we Create Multiple Where Clause Query Using Laravel Eloquent?

Hii, You can use Conditions using Array: $users = User::where([ ...READ MORE

answered Mar 30, 2020 in Laravel by Niroj
• 82,880 points
16,238 views
0 votes
1 answer

How to send email using php?

Hello @kartik 1.) Download PHPMailer, open the zip file ...READ MORE

answered Apr 1, 2020 in PHP by Niroj
• 82,880 points
1,044 views
0 votes
1 answer

Where to register Facades & Service Providers in Lumen?

Hello, To register a facade with an alias, ...READ MORE

answered Apr 6, 2020 in Laravel by Niroj
• 82,880 points
4,112 views
0 votes
1 answer

How can I update NodeJS and NPM to the next versions?

Hello @kartik, First check your NPM version npm -v 1).Update ...READ MORE

answered May 5, 2020 in Java-Script by Niroj
• 82,880 points
781 views
0 votes
1 answer

What is callback function in JavaScript?

callback is not a keyword, its just ...READ MORE

answered Jan 30, 2020 in Java-Script by Niroj
• 82,880 points
17,710 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP