JQuery

JQuery 시작하기

래머 2016. 3. 11. 12:28

jQuery Get Started(JQuery 시작하기)


Adding jQuery to Your Web Pages(JQuery를 당신의 웹사이트에추가하기)

There are several ways to start using jQuery on your web site. You can:

당신의 웹사이트에서 JQuery를 사용하기위한 다음의 몇가지 방법들이 있다:

  • Download the jQuery library from jQuery.com(JQuery.com으로부터 JQuery라이브러리 다운로드하기)
  • Include jQuery from a CDN, like Google(구글의 CDN 같은곳을 통해 JQuery를 포함시키기)

Downloading jQuery(JQuery다운로드하기)

There are two versions of jQuery available for downloading:

다운로드 가능한 두가지 버전의 JQuery라이브러리가 있다:

  • Production version - this is for your live website because it has been minified and compressed
  • 상용버전 - 이버전은 축소되고 압축되었기 때문에 당신의 라이브 웹사이트를 위한것이다.
  • Development version - this is for testing and development (uncompressed and readable code)
  • 개발버전 - 이것은 테스트 및 개발을 위한 버전이다(압축되지 않았고 읽기 가능한 코드이다)

Both versions can be downloaded from jQuery.com.

두 버전들은 JQuery.com으로부터 다운로드 할 수 있다.

The jQuery library is a single JavaScript file, and you reference it with the HTML <script> tag (notice that the <script> tag should be inside the <head> section):

JQuery라이브러리는 단일의 자바스크립트 파일이며, HTML <script> 태그를 통해서 참조할 수 있다(주의할것은 <script>태그는 <head> 섹션내부에 포함되어야 할것이다)

<head>
<script src="jquery-1.12.0.min.js"></script>
</head>

Tip: Place the downloaded file in the same directory as the pages where you wish to use it.

팁 : 당신이 사용할 장소와 같은 디렉토리에 다운로드될 파일을 위치시켜라

Note

Do you wonder why we do not have type="text/javascript" inside the <script> tag?
type="text/javascript"속성을 <script>태그 내부에 가지고 있지 않은지 놀랍지 않은가?


This is not required in HTML5. JavaScript is the default scripting language in HTML5 and in all modern browsers!

이것은 HTML5에서 요구되지 않기 때문이다. 자바스크립트는 HTML5와 현대의 모든 브라우저들에서 기본스크립트 언어이다.


jQuery CDN

If you don't want to download and host jQuery yourself, you can include it from a CDN (Content Delivery Network).

Both Google and Microsoft host jQuery.

만일 자체적으로 JQuery를 호스트하는 형태로 다운로드되기를 원하지 않는다면, 그것을 구글이나 마이크로소프트가 호스트하는 JQuery의 CDN으로 부터 포함시킬 수 있다.


To use jQuery from Google or Microsoft, use one of the following:

구글이나 마이크로소프트로부터 JQuery를 이용하기위해 다음의 하나를 사용한다:

Google CDN:

<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script>
</head>
Try it yourself »

Microsoft CDN:

<head>
<script src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.12.0.min.js"></script>
</head>
Try it yourself »
Note

One big advantage of using the hosted jQuery from Google or Microsoft:
구글 또는 마이크로소프트의 호스트를 이용하는것에 대한 하나의 큰 장점:

Many users already have downloaded jQuery from Google or Microsoft when visiting another site. As a result, it will be loaded from cache when they visit your site, which leads to faster loading time. Also, most CDN's will make sure that once a user requests a file from it, it will be served from the server closest to them, which also leads to faster loading time.
많은 사용자들은 다른 하나의 사이트를 방문할때 구글이나 마이크로소프트로부터 다운로드된 JQuery를 이미 가지고 있게된다. 결과적으로, 그들이 당신의 사이트를 방문할때 그것은 캐시로부터 로드되고, 

이것은 로딩 시간을 빠르게한다. 또한, 대부분의 CDN들은 일단 유저들로부터 파일이 요청되면, 그들로부터 가장가까운 서버로 부터 그것을 제공할것이고, 이것은 로딩시간을 빠르게 하게된다.