# Polyfill 사용하기

메서드를 사용하기 전 브라우저 호환성을 확인 하는 것은 중요합니다.[ CanIuse 사이트](https://caniuse.com/)에서도 확인이 가능하.&#x20;

만약 IE 사용이 불가능한 메서드라면 제공된 Polyfill을 사용할 수 있다. \
polyfill은 MDN 문서에서 확인이 가능하다. &#x20;

![Element.closest()의 polyfill 코드](https://1395688247-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MPJVY9pwxuf9ZCGI1gj%2F-MPiufEPpz9-QkT61eSd%2F-MPivOc3raUzz31b14yM%2Fimage.png?alt=media\&token=140d765d-375c-440e-9898-9dbbcd2890ee)

polyfill의 코드를 복사하고 polyfill 파일을 따로 생성해서 js 파일에 붙여넣기 해준다.&#x20;

![polyfill 파일을 만든 이미지](https://1395688247-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MPJVY9pwxuf9ZCGI1gj%2F-MPiufEPpz9-QkT61eSd%2F-MPix4HgDpcjMFkkaZkA%2Fimage.png?alt=media\&token=5cec7b48-4125-47d2-9af7-7f2369d3d1de)

{% hint style="warning" %}
polyfill은 html 문서에서 해석한다. 그렇기 때문에 작업(src)폴더와 배포(dist)폴더를 따로 사용하는 경우라면, 경로 문제로 인한 오류를 방지하기 위해서 html 문서가 접근 가능한 경로에 polyfill 파일을 생성하는 것을 권장한.&#x20;
{% endhint %}

![html문서에 polyfill 파일을 불러온 것, 가장 먼저 polyfill 파일을 불러왔다.](https://1395688247-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MPJVY9pwxuf9ZCGI1gj%2F-MPiufEPpz9-QkT61eSd%2F-MPiwwq0vV1vgaTte6_C%2Fimage.png?alt=media\&token=bab1a110-2712-4615-96a1-93f480ef0760)

Sass에서 mixin을 사용하기 위해서는 문서의 상단 mixin 파일을 먼저 불러와야지 mixin을 사용할 수 있. 이처럼 사용하려는 메서드를 사용하기 전에 먼저 해당 메서드의 polyfill을 먼저 불러와야 IE에서 사용이 가능하다.&#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/make-better-netflix-website/interaction/polyfill.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.
