JavaScript에서 type은 <script> 태그에 사용되어 스크립트의 MIME 타입을 정의하거나, 다양한 스크립트 유형을 지정하는 속성입니다. 일반적으로 <script> 태그에서 자주 사용하는 type 속성의 값과 그 용도는 다음과 같습니다.
// index.html
<script type="importmap">
{
"imports": {
"three": "https://cdn.jsdelivr.net/npm/three@0.161/build/three.module.js",
"jsm/": "https://cdn.jsdelivr.net/npm/three@0.161/examples/jsm/"
}
}
</script>
<script type="module" src="/main.js"></script>
// main.js
import * as THREE from "three";
import { OrbitControls } from 'jsm/controls/OrbitControls.js';
또는
<script type="importmap">
{
"imports": {
"lodash": "/js/lodash.min.js",
"moment": "/js/moment.min.js"
}
}
</script>
<script type="module">
import _ from 'lodash';
import moment from 'moment';
console.log(_.isEmpty([])); // true
console.log(moment().format('MMMM Do YYYY, h:mm:ss a')); // 현재 날짜/시간 출력
</script>
dat.gui, lil-gui 차이점 (1) (1) | 2024.09.23 |
---|---|
eslint 사용 안하기 (0) | 2024.09.18 |
properties(속성), attributes(특성) 차이점 (1) | 2024.09.17 |
canvas.toDataURL() (3) | 2024.09.16 |
property accessors, dot notation, bracket notation, 점 표기법, 대괄호 표기법, 속성접근자 (0) | 2024.09.16 |