ݺߣ

ݺߣShare a Scribd company logo
HTML5 앱과 웹사이트를 보다
  빠르게 하는 50가지 트릭
       전용우
MS Build Conference 2012
6가지 원칙
•   네트워크 요청은 빠르게 응답할 것
•   최소한의 크기로 자원을 내려 받을 것
•   효율적인 마크업 구조를 가질 것
•   미디어 사용을 개선할 것
•   빠른 자바스크립트를 작성할 것
•   어플리케이션이 어떻게 동작되는지 알고
    있을 것
네트워크 요청은 빠르게 응답할 것
3xx 리다이렉트를 피할 것


   70%




         30%
Meta-refresh 사용금지




  14%
CDN을 사용할 것
Html5 앱과 웹사이트를 보다 빠르게 하는 50가지
동시 커넥션 수를 최소화 할 것
Html5 앱과 웹사이트를 보다 빠르게 하는 50가지
커넥션을 재활용할 것


HTTP Response

HTTP/1.1 200 OK
Content-Type: application/javascript
Content-Length: 230848
Connection: Keep-Alive
최소한의 크기로 자원을 내려 받을 것
777k
Images (474k)
Scripts (128k)
Flash (84k)
HTML (35k)
Style Sheets (27k)
Other (29k)
gzip 압축을 사용할 것

Request                          Response
GET / HTTP/1.1                   HTTP/1.1 200 OK
Accept: */*                      Content-Length: 3479
Accept-Language: en-us           Expires: -1
UA-CPU: x86                      Date: Sun, 14 Mar 2010 21:30:46 GMT
Accept-Encoding: gzip, deflate   Pragma: no-cache
Host: www.live.com               Content-Encoding: gzip
HTML5 App Cache을 홵Ӛ라
Html5 앱과 웹사이트를 보다 빠르게 하는 50가지
Html5 앱과 웹사이트를 보다 빠르게 하는 50가지
자원을 캐시 가능하게 해라


Request
GET /images/banner.jpg HTTP/1.1
Host: www.microsoft.com


                   Response
                   HTTP/1.1 200 OK
                   Content-Type: image/jpeg
                   Expires: Fri, 20 Apr 2011 00:00:00 GMT
조건 요청을 보내라

Request
GET /images/banner.jpg HTTP/1.1
Host: www.microsoft.com
If-Modified-Since:
Sun, 10 Apr 2011 21:30:46 GMT

                       Response
                       HTTP/1.1 304 Not Modified
                       Content-Type: image/jpeg
                       Last-Modified:
                       Sun, 1 Mar 2011 21:30:46 GMT
효율적인 마크업 구조를 가질 것
레거시 IE모드는 http헤더를 사용


Page Meta Tag
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7">




 HTTP Header
 HTTP/1.1 200 OK
 Date: Sun, 14 Mar 2010 21:30:46 GMT
 X-UA-Compatible: IE=EmulateIE7
페이지의 위에 CSS를 넣을 것

<html>
          <head>
                   <title>Test</title>
                   <link rel="stylesheet" type="text/css"href="class.css" />
          </head>
          <body>
          … … …
          </body>
</html>
@import의 사용을 피할 것

@import url(/stylesheets/one.css);
@import url(/stylesheets/two.css);

MyHeading {
    color: red;
    font-family: 'New Century Schoolbook', serif;
    background: white;
}
inline 스타일과
       embedded 스타일은 피할 것

<html>
    <head>
              <title>Test</title>
   </head>
   <body>
              <style>
                     .item { color:#009900;}
              </style>
              <div class=‘item’>MyItem</div>
    </body>
</html>
사용하는 스타일만 CSS에 포함


#HomePage{
    color: red;
}

#ContentPage{
    color: green;
}
스크립트는 아래에 넣을 것

<html>
          <head>
                   <title>Test</title>
          </head>
          <body>
          … … …
          <script src=/slideshow/html5-50/16141568/"myscript.js" … ></script>
          </body>
</html>
중복 코드 제거할 것


<html>
          <head>
                    <title>Test</title>
          </head>
          <body>
          …
          <script   src=/slideshow/html5-50/16141568/"jquery.js" … ></script>
          <script   src=/slideshow/html5-50/16141568/"myscript.js" … ></script>
          <script   src="navigation.js" … ></script>
          <script   src=/slideshow/html5-50/16141568/"jquery.js" … ></script>
          </body>
</html>
52%
단일 프레임워크 사용

<script   src=/slideshow/html5-50/16141568/"jquery.js" … ></script>
<script   src="prototype.js" … ></script>
<script   src="dojo.js" … ></script>
<script   src="animater.js" … ></script>
<script   src="extjs.js" … ></script>
<script   src="yahooui.js" … ></script>
<script   src="mochikit.js" … ></script>
<script   src="lightbox.js" … ></script>
<script   src="jslibs.js" … ></script>
<script   src="gsel.js" … ></script>
3rd Party 스크립트 삽입하지 말 것

<script   src=/slideshow/html5-50/16141568/"facebookconnect.js" … ></script>
<script   src="facebooklike.js" … ></script>
<script   src="facebookstats.js" … ></script>
<script   src="tweetmeme.js" … ></script>
<script   src="tweeter.js" … ></script>
<script   src="tweetingly.js" … ></script>
<script   src="googleanalytics.js" … ></script>
<script   src="doubleclick.js" … ></script>
<script   src="monitor.js" … ></script>
<script   src="digg.js" … ></script>
미디어 사용의 개선
Images (474k)
Scripts (128k)
Flash (84k)
HTML (35k)
Style Sheets (27k)
Other (29k)
58
이미지 스프라이트 사용

         Multiple Files                   Image Sprite




                                  40px




                                                         40px
40px 40px 40px 40px   40px 40px              240px




        6 Images                           1 Image
      6 Connections                      1 Connection
      96k Download                       21k Download
실제 이미지 해상도를 사용해라

<html>
          <head>
                   <title>Test</title>
          </head>
          <body>
          …
          <!-- logo.gif dimensions: 500 x 400 -->
          <img src=/slideshow/html5-50/16141568/"logo.png" width="50" height="40" />
          …
          </body>
</html>
CSS3를 활용해라




border-radius:18px;
-webkit-border-radius: 100px;
-moz-border-radius: 100px;

-ms-gradient(linear, 50% 50%, 0% 34%, from(#666666), to(#666666), color-stop(.3,#333333))
-webkit-gradient(linear, 50% 50%, 0% 34%, from(#666666), to(#666666), color-stop(.3,#333333))
-moz-gradient(linear, 50% 50%, 0% 34%, from(#666666), to(#666666), color-stop(.3,#333333))
하나의 작은 크기 이미지는
      DateURI을 사용해라

<html>
          <head>
          <title>Test</title>
          </head>
          <body>
          <img src= /slideshow/html5-50/16141568/"data:image/png;base64
                  iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblA"
          alt="Red dot" />
          </body>
</html>
비디오의 미리 보기 이미지를
     만들어라
빠른 자바스크립트 작성
코드를 최소화 해라

Initial (66 Characters)
function Sum(number1, number2) {
    return (number1 + number2);
}

Characters Removed (54 Characters)
function Sum(number1,number2){return number1+number2;}

Compacted (30 Characters)
function Sum(a,b){return a+b;}
필요할 때 스크립트를 가져와라

var userTileScriptsLoaded = false;
function CustomizeUserTile(){
    if (userTileScriptsLoaded == false){
           var head = document.getElementsByTagName("head")[0];
           script = document.createElement('script');
           script.type = 'text/javascript';
           script.src = /slideshow/html5-50/16141568/&
           head.appendChild(script);
    }
}
돔의 접근을 최소화해라


function CalculateSum() {
    var leftSide = document.body.all.lSide.value;
    var rightSide = document.body.all.rSide.value;

    document.body.all.result.value = leftSide + rightSide;
}
다수의 엘리먼트를 찾을 때는
        selector api를 사용해라

function doValidation() {
    var reqs = document.querySelectorAll(".required");

    var missingRequiredField = false;
    for (var i = 0; i < reqs.length; i++) {
           if (reqs[i].value == "") missingRequiredField = true;
    }
}
마크업의 변경은 한번에 해라


function BuildUI() {
    var elm = document.getElementById('ui');
    var contents = BuildTitle() + BuildBody() + BuildFooter();
    elm.innerHTML = contents;
}
작은 크기의 돔을 유지해라
                                 Eleme
                       Element
                                 Eleme

                                 Eleme
ument    HTML   Body   Element
                                 Eleme

                                 Eleme
                       Element
                                 Eleme
내장 JSON 메서드를 사용해라



var jsObjStringParsed = JSON.parse(jsObjString);
var jsObjStringBack = JSON.stringify(jsObjStringParsed);
너의 어플리케이션의
무슨 일을 하는지 알아라
Timer 사용에 유의해라


6        6   6     6   6     6   6    6   6



    10        10        10       10



                       50
ܱٴԾپDzԹ을
             사용해라




    16.7              16.7            16.7


window.requestAnimationFrame(renderLoop);
활성화 될 때를 알아라


 Page Visibility API
document.hidden - (property);
Visibilitychange - (event);
6가지 원칙
•   네트워크 요청은 빠르게 응답할 것
•   최소한의 크기로 자원을 내려 받을 것
•   효율적인 마크업 구조를 가질 것
•   미디어 사용을 개선할 것
•   빠른 자바스크립트를 작성할 것
•   어플리케이션이 어떻게 동작되는지 알고
    있을 것
감사니다.
Ad

Recommended

Git을 조금 더 알아보자!
Git을 조금 더 알아보자!
Young Kim
ѫ도세미나
ѫ도세미나
Jiyoon Kim
An introduction to Vue.js
An introduction to Vue.js
Pagepro
HTML X CSS
HTML X CSS
Ceasr Chen
Rxjs ngvikings
Rxjs ngvikings
Christoffer Noring
HTML Dasar : #5 Heading
HTML Dasar : #5 Heading
Sandhika Galih
An introduction to Vue.js
An introduction to Vue.js
Javier Lafora Rey
공간정보거점대학 PostGIS 고급과정
공간정보거점대학 PostGIS 고급과정
JungHwan Yun
HTML Dasar : #8 Image
HTML Dasar : #8 Image
Sandhika Galih
Rxjs ppt
Rxjs ppt
Christoffer Noring
Lab #2: Introduction to Javascript
Lab #2: Introduction to Javascript
Walid Ashraf
CSS Dasar #10 : Specificity
CSS Dasar #10 : Specificity
Sandhika Galih
Quic을 이용한 네트워크 성능 개선
Quic을 이용한 네트워크 성능 개선
NAVER D2
Front end architecture
Front end architecture
Remus Langu
SJBoard Project Portfolio
SJBoard Project Portfolio
JuyoungKang7
Javascript Basics
Javascript Basics
Vishal Mittal
Vue.js Getting Started
Vue.js Getting Started
Murat Doğan
Angular Advanced Routing
Angular Advanced Routing
Laurent Duveau
React js - The Core Concepts
React js - The Core Concepts
Divyang Bhambhani
Geo server 성능향상을 위한 튜닝 기법 20111028
Geo server 성능향상을 위한 튜닝 기법 20111028
BJ Jang
React JS - A quick introduction tutorial
React JS - A quick introduction tutorial
Mohammed Fazuluddin
JavaScript & Dom Manipulation
JavaScript & Dom Manipulation
Mohammed Arif
Integration patterns in AEM 6
Integration patterns in AEM 6
Yuval Ararat
Why Vue.js?
Why Vue.js?
Jonathan Goode
Implementing DDD with C#
Implementing DDD with C#
Pascal Laurin
HTML Dasar : #4 Paragraf
HTML Dasar : #4 Paragraf
Sandhika Galih
An introduction to React.js
An introduction to React.js
Emanuele DelBono
Spring Boot Tutorial
Spring Boot Tutorial
Naphachara Rattanawilai
유니브북 출시부터 운영까지
유니브북 출시부터 운영까지
Manjong Han
EcmaScript6(2015) Overview
EcmaScript6(2015) Overview
yongwoo Jeon

More Related Content

What's hot (20)

HTML Dasar : #8 Image
HTML Dasar : #8 Image
Sandhika Galih
Rxjs ppt
Rxjs ppt
Christoffer Noring
Lab #2: Introduction to Javascript
Lab #2: Introduction to Javascript
Walid Ashraf
CSS Dasar #10 : Specificity
CSS Dasar #10 : Specificity
Sandhika Galih
Quic을 이용한 네트워크 성능 개선
Quic을 이용한 네트워크 성능 개선
NAVER D2
Front end architecture
Front end architecture
Remus Langu
SJBoard Project Portfolio
SJBoard Project Portfolio
JuyoungKang7
Javascript Basics
Javascript Basics
Vishal Mittal
Vue.js Getting Started
Vue.js Getting Started
Murat Doğan
Angular Advanced Routing
Angular Advanced Routing
Laurent Duveau
React js - The Core Concepts
React js - The Core Concepts
Divyang Bhambhani
Geo server 성능향상을 위한 튜닝 기법 20111028
Geo server 성능향상을 위한 튜닝 기법 20111028
BJ Jang
React JS - A quick introduction tutorial
React JS - A quick introduction tutorial
Mohammed Fazuluddin
JavaScript & Dom Manipulation
JavaScript & Dom Manipulation
Mohammed Arif
Integration patterns in AEM 6
Integration patterns in AEM 6
Yuval Ararat
Why Vue.js?
Why Vue.js?
Jonathan Goode
Implementing DDD with C#
Implementing DDD with C#
Pascal Laurin
HTML Dasar : #4 Paragraf
HTML Dasar : #4 Paragraf
Sandhika Galih
An introduction to React.js
An introduction to React.js
Emanuele DelBono
Spring Boot Tutorial
Spring Boot Tutorial
Naphachara Rattanawilai
Lab #2: Introduction to Javascript
Lab #2: Introduction to Javascript
Walid Ashraf
Quic을 이용한 네트워크 성능 개선
Quic을 이용한 네트워크 성능 개선
NAVER D2
Front end architecture
Front end architecture
Remus Langu
SJBoard Project Portfolio
SJBoard Project Portfolio
JuyoungKang7
Geo server 성능향상을 위한 튜닝 기법 20111028
Geo server 성능향상을 위한 튜닝 기법 20111028
BJ Jang
React JS - A quick introduction tutorial
React JS - A quick introduction tutorial
Mohammed Fazuluddin
JavaScript & Dom Manipulation
JavaScript & Dom Manipulation
Mohammed Arif
Integration patterns in AEM 6
Integration patterns in AEM 6
Yuval Ararat

Viewers also liked (6)

유니브북 출시부터 운영까지
유니브북 출시부터 운영까지
Manjong Han
EcmaScript6(2015) Overview
EcmaScript6(2015) Overview
yongwoo Jeon
[NEXT] Flask 로 Restful API 서버 만들기
[NEXT] Flask 로 Restful API 서버 만들기
YoungSu Son
RESTful API 제대로 만들기
RESTful API 제대로 만들기
Juwon Kim
REST API 설계
REST API 설계
Terry Cho
Flask, Redis, Retrofit을 이용한 Android 로그인 서비스 구현하기
Flask, Redis, Retrofit을 이용한 Android 로그인 서비스 구현하기
Manjong Han
유니브북 출시부터 운영까지
유니브북 출시부터 운영까지
Manjong Han
EcmaScript6(2015) Overview
EcmaScript6(2015) Overview
yongwoo Jeon
[NEXT] Flask 로 Restful API 서버 만들기
[NEXT] Flask 로 Restful API 서버 만들기
YoungSu Son
RESTful API 제대로 만들기
RESTful API 제대로 만들기
Juwon Kim
Flask, Redis, Retrofit을 이용한 Android 로그인 서비스 구현하기
Flask, Redis, Retrofit을 이용한 Android 로그인 서비스 구현하기
Manjong Han
Ad

Similar to Html5 앱과 웹사이트를 보다 빠르게 하는 50가지 (20)

High performance websites v1.0
High performance websites v1.0
Byungsun Youn
[2012널리세미나] 오빠~ 네이버 왜 이렇게 늦게 떠?
[2012널리세미나] 오빠~ 네이버 왜 이렇게 늦게 떠?
Nts Nuli
20131217 html5
20131217 html5
DK Lee
[전파교육] css day 2014
[전파교육] css day 2014
Kyoung Hwan Min
조은 - AMP PWA 101 [WSConf.Seoul.2017. Vol.2]
조은 - AMP PWA 101 [WSConf.Seoul.2017. Vol.2]
WSConf.
[D2 CAMPUS] 안드로이드 오픈소스 스터디자료 - HTML, Android Animation
[D2 CAMPUS] 안드로이드 오픈소스 스터디자료 - HTML, Android Animation
NAVER D2
투어팁스모바일웹 제작가이드
투어팁스모바일웹 제작가이드
병수 김
ecdevday3 효율적인 유지보수를 위한 개발 및 관리
ecdevday3 효율적인 유지보수를 위한 개발 및 관리
Kenu, GwangNam Heo
웹성능최적화 20130405
웹성능최적화 20130405
주형 전
Learning HTML5
Learning HTML5
Jin Joong Kim
2011웹표준[04] 실전예제(네비게이션,버튼,박스,포지션)
2011웹표준[04] 실전예제(네비게이션,버튼,박스,포지션)
yjartjang
Hacosa j query 6th
Hacosa j query 6th
Seong Bong Ji
What's new in IE11
What's new in IE11
Jae Sung Park
[PHPFest 2013] High performance Javascript
[PHPFest 2013] High performance Javascript
phpkorea
서버성능개선 류우림
서버성능개선 류우림
우림 류
XECon+PHPFest2014 발표자료 - 효율적인 css 개발방법 - 최대영
XECon+PHPFest2014 발표자료 - 효율적인 css 개발방법 - 최대영
XpressEngine
쉬운 예제 중심의 HTML5 / CSS / MediaQuery / JQuery 강의
쉬운 예제 중심의 HTML5 / CSS / MediaQuery / JQuery 강의
Minha Yang
JavaScript Profiling With The Chrome Developer Tools_SYS4U I&C
JavaScript Profiling With The Chrome Developer Tools_SYS4U I&C
sys4u
Top 10 Questions about HTML5
Top 10 Questions about HTML5
Jonathan Jeon
처음부터 다시 배우는 HTML5 & CSS3 1일차
처음부터 다시 배우는 HTML5 & CSS3 1일차
Michael Yang
High performance websites v1.0
High performance websites v1.0
Byungsun Youn
[2012널리세미나] 오빠~ 네이버 왜 이렇게 늦게 떠?
[2012널리세미나] 오빠~ 네이버 왜 이렇게 늦게 떠?
Nts Nuli
20131217 html5
20131217 html5
DK Lee
조은 - AMP PWA 101 [WSConf.Seoul.2017. Vol.2]
조은 - AMP PWA 101 [WSConf.Seoul.2017. Vol.2]
WSConf.
[D2 CAMPUS] 안드로이드 오픈소스 스터디자료 - HTML, Android Animation
[D2 CAMPUS] 안드로이드 오픈소스 스터디자료 - HTML, Android Animation
NAVER D2
투어팁스모바일웹 제작가이드
투어팁스모바일웹 제작가이드
병수 김
ecdevday3 효율적인 유지보수를 위한 개발 및 관리
ecdevday3 효율적인 유지보수를 위한 개발 및 관리
Kenu, GwangNam Heo
웹성능최적화 20130405
웹성능최적화 20130405
주형 전
2011웹표준[04] 실전예제(네비게이션,버튼,박스,포지션)
2011웹표준[04] 실전예제(네비게이션,버튼,박스,포지션)
yjartjang
[PHPFest 2013] High performance Javascript
[PHPFest 2013] High performance Javascript
phpkorea
서버성능개선 류우림
서버성능개선 류우림
우림 류
XECon+PHPFest2014 발표자료 - 효율적인 css 개발방법 - 최대영
XECon+PHPFest2014 발표자료 - 효율적인 css 개발방법 - 최대영
XpressEngine
쉬운 예제 중심의 HTML5 / CSS / MediaQuery / JQuery 강의
쉬운 예제 중심의 HTML5 / CSS / MediaQuery / JQuery 강의
Minha Yang
JavaScript Profiling With The Chrome Developer Tools_SYS4U I&C
JavaScript Profiling With The Chrome Developer Tools_SYS4U I&C
sys4u
Top 10 Questions about HTML5
Top 10 Questions about HTML5
Jonathan Jeon
처음부터 다시 배우는 HTML5 & CSS3 1일차
처음부터 다시 배우는 HTML5 & CSS3 1일차
Michael Yang
Ad

More from yongwoo Jeon (14)

deview2014
deview2014
yongwoo Jeon
Web Components 101 polymer & brick
Web Components 101 polymer & brick
yongwoo Jeon
Html5 시대의 웹앱 프로그래밍 방식의 변화
Html5 시대의 웹앱 프로그래밍 방식의 변화
yongwoo Jeon
asm.js
asm.js
yongwoo Jeon
Html5 use cases
Html5 use cases
yongwoo Jeon
Client side storage in html5
Client side storage in html5
yongwoo Jeon
Devfest
Devfest
yongwoo Jeon
Whats jindo
Whats jindo
yongwoo Jeon

Html5 앱과 웹사이트를 보다 빠르게 하는 50가지

  • 1. HTML5 앱과 웹사이트를 보다 빠르게 하는 50가지 트릭 전용우
  • 3. 6가지 원칙 • 네트워크 요청은 빠르게 응답할 것 • 최소한의 크기로 자원을 내려 받을 것 • 효율적인 마크업 구조를 가질 것 • 미디어 사용을 개선할 것 • 빠른 자바스크립트를 작성할 것 • 어플리케이션이 어떻게 동작되는지 알고 있을 것
  • 9. 동시 커넥션 수를 최소화 할 것
  • 11. 커넥션을 재활용할 것 HTTP Response HTTP/1.1 200 OK Content-Type: application/javascript Content-Length: 230848 Connection: Keep-Alive
  • 12. 최소한의 크기로 자원을 내려 받을 것
  • 13. 777k
  • 14. Images (474k) Scripts (128k) Flash (84k) HTML (35k) Style Sheets (27k) Other (29k)
  • 15. gzip 압축을 사용할 것 Request Response GET / HTTP/1.1 HTTP/1.1 200 OK Accept: */* Content-Length: 3479 Accept-Language: en-us Expires: -1 UA-CPU: x86 Date: Sun, 14 Mar 2010 21:30:46 GMT Accept-Encoding: gzip, deflate Pragma: no-cache Host: www.live.com Content-Encoding: gzip
  • 16. HTML5 App Cache을 홵Ӛ라
  • 19. 자원을 캐시 가능하게 해라 Request GET /images/banner.jpg HTTP/1.1 Host: www.microsoft.com Response HTTP/1.1 200 OK Content-Type: image/jpeg Expires: Fri, 20 Apr 2011 00:00:00 GMT
  • 20. 조건 요청을 보내라 Request GET /images/banner.jpg HTTP/1.1 Host: www.microsoft.com If-Modified-Since: Sun, 10 Apr 2011 21:30:46 GMT Response HTTP/1.1 304 Not Modified Content-Type: image/jpeg Last-Modified: Sun, 1 Mar 2011 21:30:46 GMT
  • 22. 레거시 IE모드는 http헤더를 사용 Page Meta Tag <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7"> HTTP Header HTTP/1.1 200 OK Date: Sun, 14 Mar 2010 21:30:46 GMT X-UA-Compatible: IE=EmulateIE7
  • 23. 페이지의 위에 CSS를 넣을 것 <html> <head> <title>Test</title> <link rel="stylesheet" type="text/css"href="class.css" /> </head> <body> … … … </body> </html>
  • 24. @import의 사용을 피할 것 @import url(/stylesheets/one.css); @import url(/stylesheets/two.css); MyHeading { color: red; font-family: 'New Century Schoolbook', serif; background: white; }
  • 25. inline 스타일과 embedded 스타일은 피할 것 <html> <head> <title>Test</title> </head> <body> <style> .item { color:#009900;} </style> <div class=‘item’>MyItem</div> </body> </html>
  • 26. 사용하는 스타일만 CSS에 포함 #HomePage{ color: red; } #ContentPage{ color: green; }
  • 27. 스크립트는 아래에 넣을 것 <html> <head> <title>Test</title> </head> <body> … … … <script src=/slideshow/html5-50/16141568/"myscript.js" … ></script> </body> </html>
  • 28. 중복 코드 제거할 것 <html> <head> <title>Test</title> </head> <body> … <script src=/slideshow/html5-50/16141568/"jquery.js" … ></script> <script src=/slideshow/html5-50/16141568/"myscript.js" … ></script> <script src="navigation.js" … ></script> <script src=/slideshow/html5-50/16141568/"jquery.js" … ></script> </body> </html>
  • 29. 52%
  • 30. 단일 프레임워크 사용 <script src=/slideshow/html5-50/16141568/"jquery.js" … ></script> <script src="prototype.js" … ></script> <script src="dojo.js" … ></script> <script src="animater.js" … ></script> <script src="extjs.js" … ></script> <script src="yahooui.js" … ></script> <script src="mochikit.js" … ></script> <script src="lightbox.js" … ></script> <script src="jslibs.js" … ></script> <script src="gsel.js" … ></script>
  • 31. 3rd Party 스크립트 삽입하지 말 것 <script src=/slideshow/html5-50/16141568/"facebookconnect.js" … ></script> <script src="facebooklike.js" … ></script> <script src="facebookstats.js" … ></script> <script src="tweetmeme.js" … ></script> <script src="tweeter.js" … ></script> <script src="tweetingly.js" … ></script> <script src="googleanalytics.js" … ></script> <script src="doubleclick.js" … ></script> <script src="monitor.js" … ></script> <script src="digg.js" … ></script>
  • 33. Images (474k) Scripts (128k) Flash (84k) HTML (35k) Style Sheets (27k) Other (29k)
  • 34. 58
  • 35. 이미지 스프라이트 사용 Multiple Files Image Sprite 40px 40px 40px 40px 40px 40px 40px 40px 240px 6 Images 1 Image 6 Connections 1 Connection 96k Download 21k Download
  • 36. 실제 이미지 해상도를 사용해라 <html> <head> <title>Test</title> </head> <body> … <!-- logo.gif dimensions: 500 x 400 --> <img src=/slideshow/html5-50/16141568/"logo.png" width="50" height="40" /> … </body> </html>
  • 37. CSS3를 활용해라 border-radius:18px; -webkit-border-radius: 100px; -moz-border-radius: 100px; -ms-gradient(linear, 50% 50%, 0% 34%, from(#666666), to(#666666), color-stop(.3,#333333)) -webkit-gradient(linear, 50% 50%, 0% 34%, from(#666666), to(#666666), color-stop(.3,#333333)) -moz-gradient(linear, 50% 50%, 0% 34%, from(#666666), to(#666666), color-stop(.3,#333333))
  • 38. 하나의 작은 크기 이미지는 DateURI을 사용해라 <html> <head> <title>Test</title> </head> <body> <img src= /slideshow/html5-50/16141568/"data:image/png;base64 iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblA" alt="Red dot" /> </body> </html>
  • 39. 비디오의 미리 보기 이미지를 만들어라
  • 41. 코드를 최소화 해라 Initial (66 Characters) function Sum(number1, number2) { return (number1 + number2); } Characters Removed (54 Characters) function Sum(number1,number2){return number1+number2;} Compacted (30 Characters) function Sum(a,b){return a+b;}
  • 42. 필요할 때 스크립트를 가져와라 var userTileScriptsLoaded = false; function CustomizeUserTile(){ if (userTileScriptsLoaded == false){ var head = document.getElementsByTagName("head")[0]; script = document.createElement('script'); script.type = 'text/javascript'; script.src = /slideshow/html5-50/16141568/& head.appendChild(script); } }
  • 43. 돔의 접근을 최소화해라 function CalculateSum() { var leftSide = document.body.all.lSide.value; var rightSide = document.body.all.rSide.value; document.body.all.result.value = leftSide + rightSide; }
  • 44. 다수의 엘리먼트를 찾을 때는 selector api를 사용해라 function doValidation() { var reqs = document.querySelectorAll(".required"); var missingRequiredField = false; for (var i = 0; i < reqs.length; i++) { if (reqs[i].value == "") missingRequiredField = true; } }
  • 45. 마크업의 변경은 한번에 해라 function BuildUI() { var elm = document.getElementById('ui'); var contents = BuildTitle() + BuildBody() + BuildFooter(); elm.innerHTML = contents; }
  • 46. 작은 크기의 돔을 유지해라 Eleme Element Eleme Eleme ument HTML Body Element Eleme Eleme Element Eleme
  • 47. 내장 JSON 메서드를 사용해라 var jsObjStringParsed = JSON.parse(jsObjString); var jsObjStringBack = JSON.stringify(jsObjStringParsed);
  • 49. Timer 사용에 유의해라 6 6 6 6 6 6 6 6 6 10 10 10 10 50
  • 50. ܱٴԾپDzԹ을 사용해라 16.7 16.7 16.7 window.requestAnimationFrame(renderLoop);
  • 51. 활성화 될 때를 알아라 Page Visibility API document.hidden - (property); Visibilitychange - (event);
  • 52. 6가지 원칙 • 네트워크 요청은 빠르게 응답할 것 • 최소한의 크기로 자원을 내려 받을 것 • 효율적인 마크업 구조를 가질 것 • 미디어 사용을 개선할 것 • 빠른 자바스크립트를 작성할 것 • 어플리케이션이 어떻게 동작되는지 알고 있을 것