ããã¯ã€ã³ã¿ãŒãããäžã§ç§ã«åºããããèšäºã®ããªãç¡æã®ç¿»èš³ã§ãã èè ã¯TJ VanTollã§ãã 圌ã¯é·å¹Žã«ããã£ãŠWebéçºã«æºãããç¹ã«æºåž¯é»è©±ã®ããã©ãŒãã³ã¹åäžã®ããã«ãµã€ããæé©åããŠããŸãã ã«ããã®äžã§ã¯ãããã€ãã®æé©åæ¹æ³ãšãããŸããŸãªããã€ã¹ã§ã®ãã¹ãçµæãèæ ®ãããŸãã
jQuery for mobileã䜿çšããå¿ èŠããããŸããïŒ
ç§ã¯ãããã®è³ªåããããŸããããã®éãã£ãšããã説æã§ããç 究ã¯è¡ãããŠããŸããã jQueryã©ã€ãã©ãªãŒã¯ã倧èŠæš¡ãã§ãè¥å€§åãããŠãããšããèšãããŸããããããã®æŠå¿µã¯çžå¯Ÿçã§ãããå®éšçãªç¢ºèªãªãã§ã¯äœã蚌æããŸããã 次ã®ããã«ãã®è³ªåãããã®ã¯æ£ããã§ãããããjQueryã®ãµã€ãºã¯ããã®ã©ã€ãã©ãªã䜿çšããŠæ©èœãæãªãããšãæåŠã§ããã»ã©åŒ·åã§ããïŒã ãã®è³ªåã«çããã«ã¯ãã¢ãã€ã«ããã€ã¹ã«ã©ã€ãã©ãªãããŒãããé床ã決å®ããå¿ èŠããããŸãã ãã®èšäºã¯ãã®åé¡ã«ç¹åããŠããŸãããæåãã<script>ã¿ã°å ã§äœãèµ·ãã£ãŠããã®ããç解ããå¿ èŠããããŸãã
<script>ã¿ã°
<script src="jQuery.js"></script>
ç§ãã¡ã¯çããã®ã³ãŒããäœåºŠãèŠãŸãããããã©ãŠã¶ãŒããã®è¡ãèŠããšã©ããªããŸããïŒ å®éãå€ãã®ã€ãã³ããçºçããŠããŸãããæãéèŠãª2ã€ã®ããã»ã¹ã®ã¿ã«é¢å¿ããããŸãã
- ãã¡ã€ã«ã®åä¿¡ïŒããã«ã¯ããã£ãã·ã¥ãŸãã¯ãããã¯ãŒã¯ããã®2ã€ã®ãªãã·ã§ã³ããããŸãïŒ;
- 解æãšã¹ã¯ãªããå®è¡ã
ãããã®åã¢ã€ãã ãåå¥ã«èŠãŠã¿ãŸãããã
jQueryãããŠã³ããŒããã
æè¯ã®çµæãåŸãããã«ããŠãŒã¶ãŒãåããŠãµã€ãã«ã¢ã¯ã»ã¹ããããã«å¿ããŠãã£ãã·ã¥ã«ããŒã¿ããªããšæ³å®ããŠããŸãã ãã©ãŠã¶ã®ãã£ãã·ã¥ã«ããŒã¿ããªãå ŽåããµãŒããŒãããã¹ãŠã®ãã¡ã€ã«ãããŠã³ããŒãããå¿ èŠããããŸãã ãã®ãããªè² è·ã®æéã枬å®ããŠã¿ãŸããããããã¯ã垯åå¹ ãšé 延ã®2ã€ã®èŠå ã®åœ±é¿ãåããŸãã
ã¹ã«ãŒãããã
垯åå¹ ã¯ããã©ãŠã¶ããµãŒããŒãããã¡ã€ã«ãããŠã³ããŒãã§ããé床ã§ãããã»ãšãã©ã®å ŽåãMbpsã§æž¬å®ãããŸãã
2012幎ãäžçäžã®ã¢ãã€ã«ãããã¯ãŒã¯ã®å¹³åé床ã¯ãäžéšã®ã¢ãžã¢è«žåœã®ã2 Mbitãããã·ã¢ãšã€ã³ãã®ã1 Mbitã®ç¯å²ã§ããã ãã¡ããããã®ããŒã¿ã¯å°ãæ代é ãã§ãããæ°ãããããã¯ãŒã¯ã¯æ¬¡ã®ãããªå€§ããªé床ãçŽæããŸãã
- Virgin Mobileã¯ã4Gãããã¯ââãŒã¯ã®ããŠã³ããŒãé床ã¯3ã6 Mbpsã§ãããšäž»åŒµããŠããŸãã
- Verizon Wirelessã¯ã4Gãããã¯ââãŒã¯ã®ããŠã³ããŒãé床ã¯5ã12 Mbpsã§ãããšäž»åŒµããŠããŸãã
- LTEãããã¯ãŒã¯ã¯ãç±³åœã§æ倧6.5 MbpsããªãŒã¹ãã©ãªã¢ã§æ倧24.5 Mbpsã®é床ãæäŸããŸãã
ãã®èšäºã¯jQueryã«é¢ãããã®ãªã®ã§ããããã®æ°å€ã䜿çšããŠjQueryãããŒããããŠããæéãå€æããŸãããã ç§ãã¡ã¯ã28.65 KBã®2.1.0ã©ã€ãã©ãªã®å§çž®ããŒãžã§ã³ã«åºã¥ããŠããŸãã
ããŠã³ããŒãé床ã1 Mbpsã®ãããã¯ãŒã¯ã§ã¯ãæ¯ç§125 KBãããŠã³ããŒãã§ããŸããã€ãŸãã1ç§ã§jQuery 4.36åããŠã³ããŒãã§ããŸãã ãŸãã¯ãããå ·äœçãªèšèªã§ïŒ
- ææªã®é床ïŒ1 MbpsïŒã§ããŠã³ããŒãããã«ã¯229msã
- äžéïŒ5 MbpsïŒã§ããŠã³ããŒãããã«ã¯46ms
- é«éïŒ12 MbpsïŒã§ããŠã³ããŒãããã«ã¯19msã
åŸã§ãããã®èšç®ã«æ»ããŸãããããã¯å€ããå°ãªããç¹å®ã®æ å ±ã§ããïŒ ããããå®éã«ã¯ããããã¯ãŒã¯åž¯åå¹ ã¯ã¢ãã€ã«Webã®çç£æ§ã«é¢ããæ倧ã®åé¡ã§ã¯ãããŸããã ããšãã°ãIlya GrigorikïŒGoogleïŒã¯ã5 Mbitã®é床ã®ãããã¯ãŒã¯ãã10 Mbitã®é床ã®ãããã¯ãŒã¯ã«åãæ¿ãããšãããŠã³ããŒãæéã¯5ïŒ ããççž®ãããªããšææããŸããã
ããã§ããããã¯ãŒã¯åž¯åå¹ ãããã«ããã¯ã§ã¯ãªãããšãããããŸãããããã®çç±ã¯äœã§ããïŒ
é 延
Webã¢ããªã±ãŒã·ã§ã³ã®ã³ã³ããã¹ãã§ã¯ãåŸ ã¡æéã¯ãµãŒããŒãžã®æ¥ç¶ã«ãããæéã§ãã é 延ã¯éåžžãRTTïŒã©ãŠã³ãããªããæéïŒã§æž¬å®ãããŸããããã¯ãä¿¡å·ããµãŒããŒã«å°éããŠã¯ã©ã€ã¢ã³ãã«æ»ãæéã§ãã
æŽå²çã«ãRTTã¯çŽ50ããªç§ãšå°ãããããããŒãœãã«ã³ã³ãã¥ãŒã¿ãŒã®é 延æéã«ã€ããŠã¯ããŸãå¿é ããŠããŸããã§ããã ããããæºåž¯é»è©±ã§ã¯ç§ãã¡ã¯ããã»ã©å¹žéã§ã¯ãããŸããã§ããã 2012幎ãç±³åœã®ã¢ãã€ã«ãããã¯ãŒã¯ã®å¹³åRTTæéã¯çŽ344ããªç§ã§ããã ãããŠãããã¯HTTPãªã¯ãšã¹ãã®é 延æéã§ãããçŸåšã¯93ããªç§ã§ãããåDNSããã³TCPãªã¯ãšã¹ãã®é 延æéã§ããããŸãã
çŸåšãå¹³åRTTã¯ãããã«æ¹åãããŠããŸãã Virgin Mobileã¯ãå¹³å4Gãããã¯ââãŒã¯ã¬ã€ãã³ã·ãçŽ150ããªç§ã«ãªã£ãããšãçºè¡šããŸããã ãããŸã§ã®ãšãããå¹³åé 延ã¯æ¹åãããŠããŸãããäŒéé床ã®æçµå¶éã«åé¡ããããé 延ãæå°éã«æããããšã¯ã§ããŸããã
ããããããããã¹ãŠã«ã¯æããé¢ããããŸãã jQueryã䜿çšãããšãã«å€§ããªé 延ãåé¿ããç°¡åãªæ¹æ³ãããããšãæãåºããŠãã ãããã©ã€ãã©ãªãåå¥ã®ãã¡ã€ã«ãšããŠããŒããã代ããã«ãã³ã³ãã³ããã¹ã¯ãªãããã¡ã€ã«ã«æ·»ä»ããŠäžç·ã«ããŒãããŸãã 以äžã®ããã«ïŒ
<!-- Before --> <script src="jQuery.js"></script> <script src="app.js"></script> <!-- After --> <script src="app.js"></script>
ãã®ç°¡åãªå€æŽã«ãããjQueryãã¢ããªã±ãŒã·ã§ã³ã«åå¥ã«ããŠã³ããŒããããšãã«çºçããé 延ããªããªããŸãã å€éšCDNããã©ã€ãã©ãªãããŒããããšãã«ãåãããšãã§ããŸãã CDNãããã€ããŒã®æçåã®ãããCDNãã£ãã·ã¥ã䜿çšããå¯èœæ§ã¯äœãããµãŒããŒããã®ããŠã³ããŒãã«ã¯ããã€ãã®æé ïŒDNSã«ãã¯ã¢ãããTCPæ¥ç¶ãGET HTTPèŠæ±ã®éä¿¡ïŒãå¿ èŠã«ãªãå ŽåããããŸãã
åã«ããããã¯ãŒã¯ããjQueryãã¡ã€ã«ãããŠã³ããŒãããã®ã«å¿ èŠãªæéãèšç®ããŸããã çµåãããJavaScriptãã¡ã€ã«ãããŒãããŠé 延ãåé¿ããå Žåãäžå質ã®ãããã¯ãŒã¯ã䜿çšããŠ50ããªç§ã§ãã¡ã€ã«ãããŠã³ããŒãã§ããããšãããããŸãã ãããããã¡ã€ã«ãããŠã³ããŒãããåŸããã©ãŠã¶ã¯ãããåŠçããŸãã ãã®ç¹ãããã«è©³ããèŠãŠã¿ãŸãããã
解æãšã¹ã¯ãªããå®è¡
ãã©ãŠã¶ã¯ãã¡ã€ã«ãããŠã³ããŒãããåŸãJavaScriptã³ãŒãããã€ãã³ãŒãã«å€æããŠå®è¡ããå¿ èŠããããŸãã ãã®ããã»ã¹ã¯éåžžã«è€éã§ããã詳现ã«æ€èšããããšãããšããã®èšäºã®ç¯å²ãã¯ããã«è¶ ããŠããŸããŸãã ä»ã®äœãã«èå³ããããŸãã
ã§ã¯ããã®ããã»ã¹ã«ã¯ã©ããããæéãããããŸããïŒ
ã¹ã¯ãªããã®è§£æãšå®è¡ã«ãããæéã調ã¹ãç°¡åãªãã¹ããäœæããŸããã
<script>var start = new Date();</script> <script> /* jQuery's minified source code in its entirety */ </script> <script>alert( new Date() - start );</script>
console.timeïŒïŒããã³console.timeEndïŒïŒãè©ŠããŸããããå€ãã¢ãã€ã«ãã©ãŠã¶ãŒã§ã¯ãµããŒããããŠããªããã䜿çšããŸããã§ããã ãããã®ã¡ãœããããµããŒããããã©ãŠã¶ãŒã§ã¯ã以åã«ææ¡ãããã®ãšã»ãŒåãçµæãåŸãããŸããã
解ææéãšå®è¡æéãå²ãåœãŠãããã«ãjQueryãã€ã³ã©ã€ã³ã¹ã¯ãªãããšããŠäœæããŸããïŒã€ãŸããHTMLããŒã¯ã¢ããã«çŽæ¥æ¿å ¥ãããã³ãŒãïŒã ããŸããŸãªãã©ãŠã¶ã§å®è¡ããçµæã以äžã«ç€ºããŸãã
ãã©ãŠã¶ | OS | JQuery 2.1.0解æ/å®è¡æéïŒããªç§ïŒ |
---|---|---|
IE 11 | Windows 8.1 | 18ã21ã14ã16ã15 |
ã¯ããŒã 33 | OS X 10.9.2 | 15ã8ã5ã7ã6 |
Safari 7 | OS X 10.9.2 | 9ã5ã3ã3ã2 |
Firefox 27 | OS X 10.9.2 | 12ã12ã11ã12ã12 |
ãµãã¡ãª | iOS 7 | 178ã125ã44ã87ã96 |
ããã©ã«ãã®Android | Android 2.2 | 1184ã268ã299ã216ã422 |
ããã©ã«ãã®Android | Android 4.0 | 603ã465ã106ã145ã243 |
ã¯ããŒã 33 | Android 4.4 | 219ã86ã38ã86ã123 |
Firefox 27 | Android 4.4 | 269ã367ã400ã381ã264 |
ãã¹ã¯ããããã©ãŠã¶ãŒãã¹ãã¯MacBook Proã§å®æœãããç§ã¯å³èã®ããã€ã¹ã§ã¢ãã€ã«ãã©ãŠã¶ãŒããã¹ãããŸããã ããŠã³ããŒãéã§ãã©ãŠã¶ã®ãã£ãã·ã¥ãã¯ãªã¢ããŸããã§ãããæŽæ°ãã¿ã³ãæ°åã¯ãªãã¯ããã ãã§ãã ããã¯èå³æ·±ãçµæã«ã€ãªãããŸãã.WebKitïŒChromeãSafariïŒã®ãã©ãŠã¶ãŒã¯æåã®èµ·åæã«ããŒã¿ããã£ãã·ã¥ã«ä¿åãããã®åŸã®ããŠã³ããŒãã®é床ã¯ã¯ããã«éããªããŸãããTridentïŒIEïŒããã³GeckoïŒFireFoxïŒã®ãã©ãŠã¶ãŒã¯ããã§ã¯ãããŸããã ãããã®ãšã³ãžã³ã®éçºè ããã®èšäºãèªãã å Žåã解æã®è©³çŽ°ã«ã€ããŠãã£ãšç¥ããããšæããŸãã ãŸããæéã®èšç®æ¹æ³ã«é¢ããä»ã®ææ¡ãããå Žåã¯ãã³ã¡ã³ãã§å ±æããŠãã ããã
IEãChromeãSafariãFirefoxã®ãã¹ãŠã®ãã¹ã¯ããããã©ãŠã¶ãŒã¯ããããç°¡åã«å®è¡ã§ããŸãã IEã§ãããå¹³åã§17ããªç§ãšããããªãè¯ãçµæã瀺ããŸããã
ããããã¢ãã€ã«ãã©ãŠã¶ã¯ãŸã£ããç°ãªãçµæã瀺ããŸããã iOS7ã®Mobile SafariãšAndroidã®Chromeã¯ããŸãæ©èœããŸãããã æšæºã®Androidãã©ãŠã¶ãŒã¯éåžžã«æªãçµæã瀺ããŸããã Android 2.2ã§ãã®ãã¹ããåããŠå®è¡ããã®ã¯1ç§ããããŸããã ãã¹ãããããã€ã¹ã®çš®é¡ã¯å€ããããŸããã§ããããä»ã®å€ãã®ããã€ã¹ã§ã¯çµæãããã«æªåãããšæãããŸãã
ç§ã®æèŠã§ã¯ãã¢ãã€ã«ãã©ãŠã¶ãç¹ã«æšæºã®Androidãã©ãŠã¶ã§ã®ãã®ãããªé ã解æãšã¹ã¯ãªããå®è¡ã¯ãjQueryã®ä»£ããã«å°ããªJavaScriptã©ã€ãã©ãªã䜿çšããããšã奜ã人ã«ãšã£ãŠå€§ããªãã©ã¹ã§ãã
ãã ãããã¹ãã«ã¯ããã€ãã®è¯ãç¹ããããŸãã ã ãŒã¢ã®æ³åã¯ããã«ãããŸããAndroid2.2ãšAndroid 4.0ã®éãã¯æããã«é¡èã§ããããã®åŸåã¯ä»åŸã远跡ãããå¯èœæ§ãé«ãã§ãããã
èŠçŽãããšãjQueryã®ãµã€ãºã¯åœŒããèšãã»ã©ã²ã©ããã®ã§ããïŒ
ããã§ãããŠã³ããŒãé床ã«åœ±é¿ãäžããå¿ èŠãªãã¹ãŠã®ææšã調ã¹ãŸããããã®è³ªåã«çãããšãã§ãã ãœãããŠã§ã¢éçºã«é¢ãã質åã«å¯Ÿããçããšåæ§ã«ãç§ãã¡ã®çãã¯ç¹å®ã®ç¶æ³ã«äŸåããŸãã åä¿¡ãããã¹ãŠã®ããŒã¿ãèŠçŽããããšããå§ããŸãããã
28.56K jQuery 2.1.0ã®ããŠã³ããŒãæéã¯æ¬¡ã®ãšããã§ãã
- æªããããã¯ãŒã¯ã§1Mbpsã®é床ã§ããŠã³ããŒããããš229msã
- 5Mbpsã®é床ã§éåžžã®ãããã¯ãŒã¯ã«ããŠã³ããŒãããå Žåã¯46msã
- 12Mbpsã®é床ã§è¯å¥œãªãããã¯ãŒã¯ã«ããŠã³ããŒãããå Žåã19msã
jQuery 2.1.0ãããŒããããšãã®é 延æéã¯æ¬¡ã®ãšããã§ãã
- ã¹ã¯ãªãããã¡ã€ã«ã«ã©ã€ãã©ãªã®å 容ãå«ããå Žåã¯0ããªç§ã
- ã©ã€ãã©ãªãåå¥ã®ãã¡ã€ã«ãšããŠããŠã³ããŒãããå Žåã¯ã150ã1000ããªç§ã
jQuery 2.1.0ã®è§£æ/å®è¡ã«ã¯ä»¥äžãå¿ èŠã§ãã
- ãã¹ã¯ããããã©ãŠã¶ã®å Žåã¯15ã20ããªç§ã
- 調æ»å¯Ÿè±¡ã®ãã¹ãŠã®ã¢ãã€ã«ãã©ãŠã¶ãŒã§ã®å¹³åèªã¿èŸŒã¿æéã¯270ããªç§ã§ãã
ãããã®æ°å€ã¯ãAndroid 2.2ã®å€ãããŒãžã§ã³ã®ãã©ãŠã¶ãŒãããŠã³ããŒãã«äœåãªæéãè¿œå ããå¯èœæ§ãããããšãæããã«ããŠããŸãã ããã¯ãã¿ãŒã²ãããªãŒãã£ãšã³ã¹ã«äŸåããŠãéçºæã«èæ ®ã«å ¥ããå¿ èŠããããŸãã ããã¯ããã©ãŒãã³ã¹ã«æªåœ±é¿ãäžããå¯èœæ§ããããŸãã
çµ±èšã調ã¹ãŠèŽè¡ãç¥ãããšããå§ãããŸãã å€ãã¢ãã€ã«ãã©ãŠã¶ããã®èšªåã®å²åãé«ãå Žåã¯ãjQueryã®äœ¿çšãåæ¢ããããšãã§ããŸãã ãã ãããã€ã³ãã¯ã©ã€ãã©ãªèªäœã§ã¯ãªããJavaScriptã³ãŒãã®åŠçæéã§ããããšã«æ³šæããŠãã ããã ããã¯ãã¹ãŠç¹å®ã®ã¢ããªã±ãŒã·ã§ã³ã«äŸåããŸããjQueryãããªããæžããã³ãŒããããéãããŒããããããšãããããã®ã©ã€ãã©ãªãããªãã®æéãç¯çŽããŸãã æåŸã«ãjQueryã®ã¢ãããŒã¯ãæžãåæ°ãæžããããã£ãšæžãããšã§ãã
ããããæ°åã«æ»ããŸãããã äžèšã®ããŒã¿ããããããã¯ãŒã¯ããjQueryãããŠã³ããŒãããã®ã«å¹³åã§çŽ50ããªç§ãããã«è§£ææéã«çŽ250ããªç§ãããããšãããããŸãã æã¯éãªãã ãšèšŒæããŸãããã äŸãšããŠAmazonãæ€èšããŠãã ããã Amazon.comã§ã®ããŒãžã®èªã¿èŸŒã¿ã100ããªç§é ããããã売ãäžãã®1ïŒ ã倱ããšäž»åŒµããŠããŸãã æ¥ç¶ãããjQueryã©ã€ãã©ãªã¯å£²äžã®3ïŒ ã®ã³ã¹ãããããããšãèšç®ããã®ã¯ç°¡åã§ãã ã²ã©ãããã«èãããŸãããjQueryã䜿çšãããšãµã€ãã®ããã©ãŒãã³ã¹ãšæ©èœãåäžãã売äžã®3ïŒ ã®æ倱ãã«ããŒã§ããã®ã§ãèæ ®ãã¹ãç¹ãããã€ããããŸãã
ã©ã€ãã©ãªãã¢ãžã¥ãŒã«ã§æ§æãããŠããããšãç解ããå¿ èŠããããŸãã ãããã£ãŠãããŠã³ããŒãé床ã«æºè¶³ã§ããªãå Žåã¯ãäžèŠãªã¢ãžã¥ãŒã«ãç°¡åã«åé€ããå¿ èŠãªã¢ãžã¥ãŒã«ã®ã¿ãæ®ãããšãã§ããŸãã ãããããããè¡ãåã«ãä»ã®åé¡ãèŠãŠã¿ãŸãããã
ãããããã¢ããªã±ãŒã·ã§ã³ã®ããã©ãŒãã³ã¹ãåäžãããæ¹æ³ã¯ä»ã«ããããããããŸãã
HTTPã¢ãŒã«ã€ãã«ãããšãå¹³åçãªWebããŒãžïŒ
- éãã¯1.7MB以äžã§ãã
- 90ãè¶ ããHTTPèŠæ±ãäœæããŸãã
- 275KB以äžã®JavaScriptã¹ã¯ãªããããããŸãã
- 1ã€ã®JavaScriptã«å¯ŸããŠ17åã®HTTPãªã¯ãšã¹ããäœæããŸãã
- 1MBã®ç»åãå«ãŸããŠããŸãã
- ããŒãžã®46ïŒ ã®ã¿ããã£ãã·ã¥ãããŸãã
ãããã£ãŠããŸãã次ã®ããšã«æ³šæããå¿ èŠããããŸãã
- CSS / JSãæå°åããå¿ èŠããããŸãã
- ãã¹ãŠã®CSS / JSãã¡ã€ã«ã1ã€ã«çµåããŸãã
- ç¹å¥ãªããŒã«ã䜿çšããŠãHTML / CSS / JSããã¥ã¡ã³ããå§çž®ããŸãã
- ç»åãå§çž®ããŸãã
- ãã©ãŠã¶ããã¡ã€ã«ããã£ãã·ã¥ã«ä¿åã§ããããã«ããŸãã
- äžèŠãªHTTPèŠæ±ãåé€ããŸãã
å€ãã®å Žåãè€æ°ã®ç»åãåé€ãããšãjQueryãåé€ãããããã¯ããã«å€§ããªçµæãåŸãããŸãã ããã€ãã®æé©åãè¡ã£ãããã¢ãã€ã«ããã€ã¹ã®ããã©ãŒãã³ã¹ã®åé¡ãåŒãç¶ãçºçããjQueryãåé€ããããšãèããŠããå Žå-å¯èœãªãã¹ãŠãå®è¡ãããã©ããããŸãã¯ä»ã®æ¹æ³ãæ®ã£ãŠãããã©ããã確èªããŠãã ããã