# 코드 분할(조각)

## 1. 코드 조각(spliting)&#x20;

&#x20;코드 나누기로 배포 전 코드를 나누어서 애플리케이션의 성능을 최적화 하는 것을 말한다. 나누어진 코드를 청크(chunk)라고 한다.

![코드 조각이란? ](/files/-MVMtozzcJuYxvadJQiM)

위의 그림을 보고 아래 `import()` 문법의 코드를 보면 이해가 훨씬 쉽다.&#x20;

## **2. import() 문법**&#x20;

**Before**

```javascript
import { add } from './math';

console.log(add(16, 26));
```

**After**

```javascript
import("./math").then(math => {
  console.log(math.add(16, 26));
});
```

## 3. 청크(chunk)란?&#x20;

어느 큰 덩어리(조각)를 나타낸다. 조각이라고 하니 컴포넌트와 같은 역할을 하는 거라고 오해 할 수 있지만 컴포넌트 처럼 독립적으로 사용할 수 없다.&#x20;

![청크란? ](/files/-MVMtsqocvyhULn63pn8)

## 4. 참고&#x20;

* [React import() 코드 분할 ](https://ko.reactjs.org/docs/code-splitting.html#import)&#x20;


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://shhn0509.gitbook.io/react/react-study/react-2/undefined.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
