일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | |
7 | 8 | 9 | 10 | 11 | 12 | 13 |
14 | 15 | 16 | 17 | 18 | 19 | 20 |
21 | 22 | 23 | 24 | 25 | 26 | 27 |
28 | 29 | 30 | 31 |
- ignore padding
- BFC
- 화살표2개
- ㅡ
- alias설정
- QueryClient
- react
- transition
- BlockFormattingContext
- 서초구보건소 #무료CPR교육
- useQueryClient
- 제어컴포넌트
- debouncing
- 조건부스타일
- 부모요소의 패딩 무시
- es6
- DOM
- 함수형프로그래밍
- vite
- twoarrow
- 부모패딩
- CustomHook
- ?? #null병합연산자
- 문제해결
- accordian
- tailwindCSS
- 리액트
- Carousel
- createPortal
- parent padding
- Today
- Total
프론트엔드 첫걸음
createDocumentFragment 본문
const docFragment = document.createDocumentFragment();
비어있는 documentFragment 객체를 만드는 함수
const docFragment = document.createDocumentFragment();
for(let i = 0; this.#slideNumber; i++) {
const li = document.createElement('li');
li.dataset.index = i;
docFragment.appendChild(li);
}
this.wrapperEl.querySelector('ul').appendChild(docFragment);
비어있는 객체에 li를 넣은뒤에 빈객체에 차례로 넣고, documentFragment객체를 ul안에 넣어서
동적인 list를 만들 수 있다. 이 방법을 사용하면 for문안에서 매번 appendChild 하는것보다(돔 조작을 1번만 해도 되니까) 속도가 더 빨라진다.
[참고]
https://stackoverflow.com/questions/38260907/do-i-need-to-use-documentfragment-to-insert-ul-list%EF%BB%BFhttps://blog.hao.dev/web-api-appendchild-v-s-createdocumentfragment
Web API: appendChild V.S. createDocumentFragment · Hao's learning log
All the JavaScript rendering libraries and frameworks we use, all boils down to the fundamental web APIs at the end of the day. People are so used to work with the high-level React APIs or Vue syntaxes (me included), we forget the raw and interesting layer
blog.hao.dev
See the Pen Untitled by JEONG (@cona) on CodePen.
'개발 공부 > Javascript' 카테고리의 다른 글
함수에 매개변수로 들어가 있는 ...은 rest parameter (0) | 2023.03.24 |
---|---|
함수형 프로그래밍 pipe (0) | 2023.03.24 |
css filter를 사용한 색상 반전 모드 (0) | 2023.01.29 |
카드 스크롤 애니메이션 1 - (카드 슬라이딩 + 플립) (0) | 2023.01.20 |
클로저 (0) | 2022.10.08 |