Language/JavaScript (WEB)

๐ŸŒ text/javascript ์™€ application/javascript ์ฐจ์ด์ 

์ธํŒŒ_ 2022. 3. 11. 17:36

text/javascript-application/javascript

๋‹ค์–‘ํ•œ script ํƒœ๊ทธ ํ‘œ๊ธฐ๋ฒ•

๋ช‡๋ช‡ ์›นํŽ˜์ด์ง€๋ฅผ ๋ณด๋ฉด(ํ‹ฐ์Šคํ† ๋ฆฌ ํฌํ•จ) ์Šคํฌ๋ฆฝํŠธ ํƒœ๊ทธ์— ์ž๋ฐ”์ŠคํŠธ๋ฆฝํŠธ์˜ ๋งˆ์ž„ํƒ€์ž…์œผ๋กœ type=text/javascript๋ฅผ ์‚ฌ์šฉํ•˜๋Š” ๊ฑธ ๋ณผ ์ˆ˜ ์žˆ๋‹ค. ๊ทธ๋Ÿฐ๋ฐ ์–ด๋–ค ๋‹ค๋ฅธ ์›นํŽ˜์ด์ง€์—์„œ๋Š” type=application/javascript๋กœ ์‚ฌ์šฉํ•œ๋‹ค. ๋ณดํ†ต scriptํƒœ๊ทธ๋Š” ๊ทธ๋ƒฅ ๋ฐ”๋กœ ์ •์˜ํ•˜๊ณ  src์†์„ฑ์œผ๋กœ ์†Œ์Šค ๋งํฌ๋ฅผ ์ง€์ •ํ•˜๊ณ  ๋งˆ๋Š”๋ฐ ์ € type์†์„ฑ ์ง€์ •๋ฌธ์€ ๋ฌด์—‡์„ ๋œป ํ• ๊นŒ? ์ด๋ฒˆ ํฌ์ŠคํŒ…์€ ์ด ๋‘˜์˜ ๋ช…ํ™•ํ•œ ์ฐจ์ด์ ์„ ์ •๋ฆฌํ•˜๋Š” ์‹œ๊ฐ„์„ ๊ฐ€์ ธ๋ณด์ž.

<script language="javacript">
</script>

<script type="text/javascript">
</script>

<script type="application/javacript">
</script>

 

text/javascript vs application/javascript

๊ฐ„๋‹จํ•˜๊ฒŒ ๋‘˜์„ ๋น„๊ตํ•˜๋ฉด ์•„๋ž˜ ํ‘œ์™€ ๊ฐ™๋‹ค.

text/javascript application/javascript
HTML 4.01 (1999) ์ŠคํŽ™ RFC 4329 (2006) ์ŠคํŽ™
HTML4, HTML5 ์ง€์› HTML5 ์ง€์›
Obsolete (๊ตฌ์‹) Now Recommended (์ถ”์ฒœ)

์ด๋ ‡๊ฒŒ ๋ณด๋ฉด application/javascript๊ฐ€ ์ตœ์‹  ์ŠคํŽ™์ด๋‹ˆ ์ตœ์‹ ๊ฑธ๋กœ ์‚ฌ์šฉํ•ด์•ผ๊ฒ ๋ผ ์ƒ๊ฐํ•  ์ˆ˜ ์žˆ๋‹ค. ํ•˜์ง€๋งŒ ๋ฌธ์ œ๋Š” ์„œ๋น„์Šค์—์„œ ์ง€์›ํ•˜๋Š” ๋ธŒ๋ผ์šฐ์ €์˜ ๋ฒ”์œ„์ด๋‹ค. application/javascript๋ฅผ ์‚ฌ์šฉํ•  ๊ฒฝ์šฐ์—๋Š” IE8 ์ดํ•˜๋Š” ์ง€์›์ด ๋˜์ง€ ์•Š๊ฒŒ ๋œ๋‹ค.

'application/javascript'๋Š” RFC4329์— ์„ธ๊ณ„ ํ‘œ์ค€์œผ๋กœ ๊ธฐ์กด์˜ ์ž๋ฐ”์Šคํฌ๋ฆฝํŠธ ์„ ์–ธ ๋Œ€์‹  ์ด๋ ‡๊ฒŒ ์„ ์–ธํ•˜๋ผ๊ณ ๋Š” ํ‘œ์ค€์œผ๋กœ ์ œ์ •ํ•œ ๋ฌธ์žฅ์ด๋‹ค. ํ•˜์ง€๋งŒ ์ด๋Š” HTML5์—์„œ๋Š” ๋™์ž‘ํ•˜์ง€๋งŒ, ํŠน์ • ๋ธŒ๋ผ์šฐ์ €์—์„œ ์ง€์›ํ•˜์ง€ ์•Š๋Š” ๋ฒ„๊ทธ ๋“ฑ์œผ๋กœ ์ธํ•ด ๊ทธ์ € ๋ง๋ฟ์ธ ํ‘œ์ค€์ผ ๋ฟ์ด๋‹ค. ๊ฑฐ๊ธฐ๋‹ค application/javascript๋ฅผ ๋ช…์‹œํ• ์‹œ, ํ•˜์œ„ ๋ธŒ๋ผ์šฐ์ €์—์„œ const ํ‚ค์›Œ๋“œ๊ฐ€ ๋จนํžˆ์ง€ ์•Š์œผ๋ฉฐ, ๋ณ€์ˆ˜ ๋“ฑ์„ ์ฐพ์ง€ ๋ชปํ•˜๋Š” ๋“ฑ ์ •์ƒ์ ์ธ ์Šคํฌ๋ฆฝํŠธ ๊ธฐ๋Šฅ์ด ๋˜์ง€ ์•Š๊ธฐ๋„ ํ•œ๋‹ค.

๋ฐ˜๋ฉด <script></script>์˜ ๊ฒฝ์šฐ๋Š” ๋ธŒ๋ผ์šฐ์ € ์—”์ง„์—์„œ <script type="text/javascript"></script>์œผ๋กœ ์žฌ๋ฒˆ์—ญํ•ด์„œ ํ•ด์„ํ•œ๋‹ค๊ณ  ํ•œ๋‹ค. ๊ทธ๋ž˜์„œ ๋ช‡๋ช‡ ์›น์‚ฌ์ดํŠธ๋“ค์„ ๋ณด๋ฉด ์–ด๋–ค ๊ณณ์€ <script></script> ๋˜ ์–ด๋–ค ๊ณณ์€ <script type="text/javascript"></script>์„ ์ฆ‰ ๋‘ ๊ฐœ๋ฅผ ๋ฒˆ๊ฐˆ์•„ ์‚ฌ์šฉํ•˜๊ธฐ๋„ ํ•œ๋‹ค


์ตœ์ข… ์ •๋ฆฌํ•˜์ž๋ฉด, ์•„๋ฌด๋ฆฌ HTMLํ‘œ์ค€์ด๋ผ๊ณ  ํ•˜์ง€๋งŒ, ๋ง๋กœ๋งŒ ํ‘œ์ค€์ผ๋ฟ ๊ตณ์ด ์“ฐ์ง€ ์•Š์•„๋„ ์ „ํ˜€ ๋ฌธ์ œ๊ฐ€ ์—†์œผ๋‹ˆ ๊ทธ๋ƒฅ ์ง€๊ธˆ์ฒ˜๋Ÿผ ์‚ฌ์šฉํ–ˆ๋“ฏ์ด ๋นˆ์นธ์œผ๋กœ ๋†”๋‘๋ฉด ๋œ๋‹ค.

<script language="javacript"></script>๋Š” ์•„์ฃผ ์ดˆ์ฐฝ๊ธฐ์— ์“ฐ์˜€์œผ๋‚˜ ์ง€๊ธˆ์€ ์‚ฌ์šฉํ•˜์ง€ ์•Š๋Š”๋‹ค.

# ์ฐธ๊ณ ์ž๋ฃŒ

https://pshcode.tistory.com/43

https://sayit.tistory.com/entry/textjavascriptVSapplicationjavascript-%EC%96%B4%EB%96%A4%EA%B2%83%EC%9D%84-%EC%82%AC%EC%9A%A9%ED%95%B4%EC%95%BC-%ED%95%98%EB%8A%94%EA%B0%80