티스토리 뷰

제이쿼리를 사용하는 방법으로는 크게 두 가지 방법을 사용한다.

 

프로젝트 폴더 내에 jquery 파일을 위치시키고 <script>태그를 이용해서 연결하거나

CDN (content delivery network)을 이용하여 웹에 있는 jquery소스를 가져와 사용할 수 있다.

 


1. js파일을 직접 사용하는 방법

 

https://jquery.com/download/

 

Download jQuery | jQuery

link Downloading jQuery Compressed and uncompressed copies of jQuery files are available. The uncompressed file is best used during development or debugging; the compressed file saves bandwidth and improves performance in production. You can also download

jquery.com

위의 사이트에 들어가보면

 

위와 같이 다양한 선택지가 존재한다. 

직접 확인해보면 uncompressed와 compressed 말그대로 압축되지 않은, 압축된 파일이다.

 

compressed
uncompressed

그리고 몇 가지 기능이 제거된 slim 버전도 있다.

 

그러면 https://code.jquery.com/jquery-3.6.0.js

에 있는 코드를 메모장에 복사 붙여넣기 한 뒤에

파일명을 jquery-3.6.0.js로 변경한뒤에 프로젝트 폴더 내에 javascript 폴더 하위에 위치 시켜주면 된다.

 

그리고 html 파일에서 script 태그를 사용해 아래와 같이 작성해주면 된다.

<script src="javascript/jquery-3.6.0.js" type="text/javascript"> </script>

 


2. CDN을 이용한 방법

 

https://developers.google.com/speed/libraries#jquery

 

Hosted Libraries  |  Google Developers

A stable, reliable, high-speed, globally available content distribution network for the most popular open-source JavaScript libraries.

developers.google.com

구글 CDN 페이지에서 

 

원하는 버전의 jquery를 복붙해서 html에 넣어주기만 하면 된다. (매우 쉽다)

 

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>

그 밖에도 얼마든지 다른 방법도 있지만, 위의 두가지 방법을 추천한다. 

https://code.jquery.com/jquery-3.6.0.js 사이트의 코드를 직접 링크해서 사용할 수 도 있지만,

인코딩 방식의 차이로 인해 한글이 깨지는 현상이 발생할 수 있다.

 

'Web Programming > JavaScript' 카테고리의 다른 글

Javascript 객체 종류 간단 정리  (0) 2019.06.24
댓글
반응형
«   2024/04   »
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
글 보관함