HTML5㧠Speed Test, Navigation Timing APIã«ããæ§è½ãã¼ã¿åé
ä»æ¥ã¯ãHTML5 Advent Calendar 2011 9æ¥ç®ã§ãã
ä½ãæ¸ããããã¿ã«è¿·ããã²ãããHTML5ã®ãã¤ãã¼ãªAPIãããã£ã¦ããã¾ããã
FullScreen API/Page Visibility API ãæ¢ã« ç»å ´ãã¦ãã¾ãã @sada_h ãããã Quota Management API ã¯ãããã¨ã奨ããåãã¾ããããããã« Quota管çã ãã§ãã¿ãå±éããã®ã¯è¾ããéæ¹ã«æ®ãã¦ãã¾ããã
ãããªæããµã¨è¦ãããã®ããNavigation Timing APIãããã¤ãã¼ã ã¨æãã¾ããããä»åãã®APIã®ç´¹ä»ã¨ãã¢ãããã¦ããã ãã¾ãã
Navigation Timing API
ããã£ãã Navigation Timing API ã¯ä½ãããAPIãï¼ ãåç´ã§ãã
ããã©ã¦ã¶ã¼ãWebã®ç»é¢ã表示ããæã«ã©ãã«ã©ãã ãæéãããã¦ãããç¥ãAPIãã§ãã
ãã©ã¦ã¶ã§ç»é¢ã表示ãããã¾ã§ã¯ããã¤ãã®æ®µéã«åããã¦ãã¾ãã大éæã«åé¡ããã¨ãDNSãå¼ãã¦ãµã¼ãã®IPã¢ãã¬ã¹ãåå¾ãããããããã¯ã¼ã¯ã®æ¥ç¶å¦çãããæéãå®éã«HTMLãã¼ã¿ãããåãããæéã»ããã¦æç»ãè¡ãæéãªã©ã§ãã
Navigation Timing API ã¯ããããã©ã¦ã¶ã¼å
é¨ã§è¡ããããç´°ããå¦çãå¤ããã¿ã¤ãã³ã°ã§ãã®æå»ãè¨é²ãã¦ããã¦æ§è½è©ä¾¡ããã¥ã¼ãã³ã°ã«çãããã¨ããAPIã§ãã
ç¾å¨(2011å¹´12æ) When can I use Navigation Timing API?ãè¦ã㨠Chrome6以ä¸/FireFox4以ä¸/IE9以ä¸/Android4 以ä¸ã§å©ç¨ã§ããAPIã§ããHTML5é¢é£APIã®ä¸ã§ãæ¯è¼çåºç¯å²ã«ãµãã¼ãããã¦ããAPIã§ããã
使ãã®ã¯ç°¡åããã©ã¦ã¶ã¼ä¸ã§ F12 ãæ¼ã㦠JavaScript ã³ã³ã½ã¼ã«ãéãã¾ãããããã㧠window.performance ã¨æã£ã¦åºã¦ãããªãã¸ã§ã¯ããããï¼æå»ã®ãã¼ã¿ãå
¥ã£ããªãã¸ã§ã¯ãï¼ã§ããæä½ããã¡ã½ãããã³ã¼ã«ããã¯ãä½ãããã¾ããããã ãªãã¸ã§ã¯ãã®ããããã£ã«å¤ãå
¥ã£ã¦ããã ãã§ãã
Navigate Timing APIã®ä¸èº«ã®èª¬æã«å
¥ãã¾ããããã®APIã§å¾ããã window.performance ãªãã¸ã§ã¯ãã¯å¤§ãã navigation 㨠timing ã®ï¼ã¤ã®ããããã£ãæã£ã¦ãã¾ãã
window.performance.navigation
windows.performance.navigation ã«ã¯ããã®ãã¼ã¸ã«ã©ããã£ã¦æ¥ãã®ãã¨ããæ
å ±ãä¿åããã¦ãã¾ãã
windows.performance.navigation.typeã®å¤ã¯ã
- 1 :ãªãã¼ããè¡ã£ã¦ãã¼ã¸ãèªã¿è¾¼ãã ãã¨ã示ãã
- 2 :ãã©ã¦ã¶ã¼ã®é²ãã»æ»ãã¨ãã£ããã¹ããªã¼æ å ±ã使ã£ã¦ãã¼ã¸ãèªã¿è¾¼ãã å ´åã
- 0 :ãã以å¤ã®å ´åãä¾ãã°ã¯ãªãã¯ãç´æ¥URLãæã¡è¾¼ãã ããã¦ãã¼ã¸ã«ãã©ãçããå ´åã
ãããã®æä½ã®éãã§ãã¼ã¸ã®è¡¨ç¤ºé度ã¯å¤§ããå¤ããã¾ãã®ã§æ§è½å¤ãè©ä¾¡ããå ´åã«ã¯ãã¡ããã¨åºå¥ãããã¨ãå¿ è¦ã¨ãããã¨ã ã¨æããã¾ãã
window.performance.timing
ãã®ãªãã¸ã§ã¯ãã«ã¯ãå®éã®æ§è½è©ä¾¡ãè¡ãã¿ã¤ãã³ã°é
ç®ã§ã®æå»ï¼ã¨ããã¯ã¿ã¤ã ï¼ãæ ¼ç´ããã¦ãã¾ããæ°ãå¤ãã®ã§å
¨ã¦ã®èª¬æã¯ãã¾ããããããããã®ããã»ã¹ã®éå§ã¨çµäºã®ã¿ã¤ãã³ã°ã«ååãã¤ãã¦ãããããããå¼ãç®ãããã¨ã§ããªç§ã®ãªã¼ãã¼ã§å¦çæéãè©ä¾¡ãããã¨ãã§ãã¾ãã
W3Cã® Navigation Timing API仕様ã®å³ãæåããã¨ããããããã§ãã
(å³ã¯W3Cä»æ§ããå¼ç¨)
ä¸è¨ã®å³ãã大éæã«å¤§ããã
- DNS : DNSãµã¼ãããIPã¢ãã¬ã¹ãåå¾ããæé
- TCP : Webãµã¼ãã¨ã®TCPæ¥ç¶ãå¦çãå®äºããã¾ã§æé
- HTTP(Request+Response): Webãµã¼ã㨠HTTP ã®ãªã¯ã¨ã¹ãã»ã¬ã¹ãã³ã¹å¦çã«ãããæé
- DOM(Processing)ï¼ãã©ã¦ã¶ã§DOMã®æ§ç¯å¦çãè¡ã£ã¦ããæé
- Load(onLoad): windowã documentãèªã¿è¾¼ã onload ã¤ãã³ããè¡ããã¦ããæé
ã«ãããã¾ãã
ãããæ©éè¦ã¦ã¿ããã
ããã®ãµã¤ãã
http://html5.ohtsu.org/html5advent2011/
ã§ãNavigation Timing APIãããã©ã¦ã¶å¦çæéãè¦ããã¢ãµã¤ããä½ãã¾ããã
表示ã¯ãã®ãããªæãã§ãã
ãªã³ã¯ãæ»ã£ããããªãã¼ãããããç´æ¥ã¢ã¯ã»ã¹ããããã©ã¦ã¶ã¼å¤ãã¦è©¦ãããããã¨ãã©ã®ãããªã¨ããã§ã©ãå¦çæéãå¤ãã£ã¦ããã®ãè¦ãã¦é¢ç½ããã¨æãã¾ãã
ä»å表示ãã·ã³ãã«ãªã³ã³ãã³ããªã®ã§ãã¾ãããªã¨ã¼ã·ã§ã³ããªãã§ããããã¾ããµã¤ããä½ãã¨HTML5ã ã㧠Speed Test ã®ãããªãã¨ãã§ãããã¨æãã¾ãã
æ§è½ãã¼ã¿ãåéã»è¡¨ç¤ºã¸
å
ç¨ã®ãã¢ã§ã¦ã¼ã¶ããã¯ãã®ãµã¤ããè¦ããã©ãã ãå¦çã«æéãããã£ã¦ãããã¨ãããã¨ããããã¾ããããä»åº¦ã¯ãµã¼ã管çè
ã®ç«å ´ã§èããã¨ããã¨èªåã®ãµã¤ãã«ã¢ã¯ã»ã¹ãã¦ããã¦ã¼ã¶ãã©ãã ãå¦çã«æéãããã£ã¦ãããæ°ã«ãªãã§ãããã
èªåã管çããWebãµã¤ããæé«ã«ãã¥ã¼ãã³ã°ã§ããããã¦ã¼ã¶ã®ãã©ã¦ã¶ã¼å¦çæéãç´°ããåå¾ã§ããã®ã¯æå³ã®ãããã¨ã§ããããã§ä¸è¨ã®ãããªä»çµã¿ã®ã¢ããªãä½ãã¾ããã
Node.js ãµã¼ãã§ã¯ã¦ã¼ã¶ãã³ã³ãã³ãã表示ãããã¼ã¿ã«ã®æé㨠navigation ã¿ã¤ããåå¾ãã¦ãã¾ãããããçµ±è¨æ
å ±ã¨ãã¦ãªã¢ã«ã¿ã¤ã ã«è¡¨ç¤ºãããã¨ãå¯è½ã§ãã
(æ³¨ï¼ Joyent ã® no.de ãµã¼ãã¹æä¾ã®çµäºã«ä¼´ãä¸è¨ãµã¼ãã¹ãåæ¢ãã¾ããã)
å®éã«åä½ãããµã¼ãã¯ã
http://shigeki.no.de
ã§ç¨¼åãã¦ãã¾ããï¼ãã©ã¦ã¶è¡¨ç¤ºã®ãã¼ã¿ã«ã®æé㨠navigation ã¿ã¤ã以å¤ã¯åå¾ãã¦ãã¾ãããï¼ï¼æä¸ç¨åº¦ã¯ãã®ã¾ã¾ç¨¼åãã¦ããã¾ããï¼
ä¸è¨ã«ã¢ã¯ã»ã¹ããã¨ã
ã®ãããªçµ±è¨æ
å ±ãè¦ããã¾ãããã®ãã¼ã¸ã«ã¢ã¯ã»ã¹ããéå»ã®ã¦ã¼ã¶ã®è¡¨ç¤ºæéã®åå¸ããªã¢ã«ã¿ã¤ã ã§è¦ããã¨ãã§ãã¾ãã
ã¾ã¨ã
ãã®ããã«æ§è½æ
å ±ãåå¾ããç´°ãããã¥ã¼ãã³ã°ãè¡ãããå¿«é©ãªç°å¢ãã¦ã¼ã¶ã«æä¾ãã¦ããéç¨ããä»å¾ã¾ãã¾ãéè¦ã«ãªã£ã¦ãããã®ã¨æããã¾ãã
ä»ã«è±æã®è¨äºã¨ãã¦ãHTML5Rocksã®Measuring Page Load Speed with Navigation Timingãé常ã«åèã«ãªãã¾ããããã§ç´¹ä»ããã¦ããèè
ãä½æãã Chrome Extension Page Speed Testã使ãã¨éå»é²è¦§ãããµã¤ãã®æ§è½å¤ã Web SQL ã§ãã¼ã«ã«ã«ä¿ç®¡ããæç³»åã§ã©ãå¤ãã£ã¦ãããã°ã©ãã§è¦ããã¨ãã§ãã¾ããä¸åº¦ã試ããã ããã