웹 사이트에서 jQuery를 사용하는 방법에는 여러가지가 있습니다.

 

1. jQuery.com에서 jQuery 라이브러리 다운

 

2. Google과 같은 CDN의 jQuery 포함

 

 

 

 

--1. jQuery.com에서 jQuery 라이브러리 다운--

 

jQuery 라이브러리는 단일 JavaScript 파일이며, HTML <script> 태그로 참조합니다.

( <script> 태그는 <head> 섹션 안에 있어야합니다. )

 

1
2
3
<head>
<script src="jquery-3.2.1.min.js"></script>
</head>
cs

 

 

 

 

 

중요:다운로드 한 파일을 사용하려는 페이지와 같은 디렉토리에 저장해주세요.

 

 

<script> 태그안에 type = "text/javascript"가 없는 이유는 자바 스크립트는

 

HTML5와 모든 최신 브라우저에서 기본 스크립팅 언어이기 때문입니다.

 

 

 

--2. Google과 같은 CDN의 jQuery 포함--

 

jQuery를 직접 다운로드,호스트 하지 않으려면 CDN(Content Delivery Network)에서 포함시킵니다.

 

Google과 Microsoft는 모두 jQuery를 호스팅합니다.

 

-Google CDN-

 

1
2
3
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
</head>
cs

 

 

 

 

 

 

-Microsoft CDN-

1
2
3
<head>
<script src="https://ajax.aspnetcdn.com/ajax/jQuery/jquery-3.2.1.min.js"></script>
</head>
cs

 

 

 

 

 

다른 사이트를 방문 할 때 많은 사용자들은 이미 Google 또는 Microsoft의 jQuery를 다운했습니다.

 

결과적으로 사이트를 방문 할 때 캐시에서 로드되므로 로드 시간이 빨라집니다.

 

따라서, Google 또는 Microsoft의 호스팅 된 jQuery를 이용하는 것이 효율적입니다.

 

 

 

출처:https://www.w3schools.com/jquery

'똥 싸기 > jQuery' 카테고리의 다른 글

[jQuery]숨기기/표시  (0) 2017.09.13
[jQuery]이벤트  (0) 2017.09.11
[jQuery]셀렉터  (0) 2017.09.11
[jQuery]구문  (0) 2017.09.11
[자바스크립트]자바스크립트 소개  (0) 2017.08.27

+ Recent posts