3

I noticed that there's a whole bunch of different content types, some of them seem redundant.

Wouldn't a js file that's served as text/plain work just as well as if it was served with text/javasctipt?

I plan on making a page that's serve-able as a ajax/json/jsonp file (with or without a callback) or as a plain page that users on a dumb phone or with no js can view as a text file.

Is there any disadvantage as always displaying a page as text/plain ? Will it ever be a problem if I'm getting it as a script? What about the inverse?

1

3 Answers 3

3

Wouldn't a js file that's served as text/plain work just as well as if it was served with text/javasctipt?

Only if it would be executed as JavaScript regardless. If text/plain meant something to the client distinct from text/javascript then the effects would (could) be different. Fortunately it usually doesn't when the browser loads it due to a <script> tag.

Sign up to request clarification or add additional context in comments.

Comments

2

An advantage of using text/javascript is that it will allow you to include non '.js' postfixed files and they will be rendered as javascript.

For instance, I usually have a global.config file - which is a javascript written configuration object. I can use the postfix '.config' which is very helpful visually - but still use have it render as javascript.

4 Comments

What do you mean "rendered as javascript" ?
I think interpreted is a better word.
@Blender: won't the js still run tho?
If it's included in a <script> tag, sure.
0

When a Javascript is inserted dynamically, the navigator will give you correct events and states of reception (readyState with Intrenet Explorer, onload with FireFox) if the content is type "text/javascript". It can make wrong or lazy response if it's "text/plain".

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.