ãã®æ°å€ã¯ãJavaScriptã³ãŒãã®
å¢å ãWebãããžã§ã¯ãã®ããã©ãŒãã³ã¹ã«æªåœ±é¿ãäžããããšã瀺ããŠããŸãã ãããããã«ç¶ãå Žåãããã«äžéããŒãžãããŒããããšãã«ãå°ãªããšã400 Kbã®JSã³ãŒãã転éãããŸãã ãããŠãããã¯è»¢éãããããŒã¿ã®éã§ãã ä»ã®ããã¹ããªãœãŒã¹ãšåæ§ã«ãJavaScriptã³ãŒãã¯ã»ãšãã©ã®å Žåãå§çž®åœ¢åŒã§éä¿¡ãããŸãã ãµãŒããŒããã¯ã©ã€ã¢ã³ãã«ã³ãŒãã転éãããšãã«éåžžè¡ãããã®ã¯ãããããå§çž®ã ãã§ãã
æ®å¿µãªãããç¹å®ã®ãªãœãŒã¹ã®è»¢éæéãççž®ããããšã¯ãããã©ãŒãã³ã¹ããšåŒã°ãããã®ã«å€§ããè²¢ç®ããŸãããå§çž®ã¯ãã¹ã¯ãªãããå®å
šã«ããŒããããåŸã®ã¹ã¯ãªããã®è§£æãšåŠçã«ãããæéã«ã¯åœ±é¿ããŸããã
ãµãŒããŒã400 KBã®å§çž®JSã³ãŒããã¯ã©ã€ã¢ã³ãã«éä¿¡ããå Žåãåä¿¡ããããŒã¿ã解åããåŸã«ãã©ãŠã¶ãŒãåŠçããå¿
èŠãããå®éã®ã³ãŒãéã¯ã¡ã¬ãã€ãé åã«ãªããŸãã ããŸããŸãªããã€ã¹ããã®çš®ã®äœæ¥ãã©ã®çšåºŠããŸãåŠçã§ãããã¯ãããã€ã¹èªäœã«äŸåããŸãã ããã«ã€ããŠ
ã¯å€ãã®ããšãæžãã
ãŠããŸããããã®æéã®ããã«éåžžã«æ®éã§ããã³ãŒãã®éã解æããããã«å¿
èŠãªæéã¯ãããã€ã¹ã«ãã£ãŠå€§ããç°ãªããšèªä¿¡ãæã£ãŠèšãããšãã§ããŸãã
ããšãã°ã
ãã®åçŽãªãããžã§ã¯ããã芧ãã ããã ããŒãžã®èªã¿èŸŒã¿äžã«ãçŽ23 Kbã®éå§çž®JSã³ãŒããã¯ã©ã€ã¢ã³ãã«è»¢éãããŸãã 2017幎åã°ã«ãªãªãŒã¹ãããMacBook Proã§åäœããChromeã¯ããã®ããªãå°éã®ã³ãŒããçŽ25ããªç§ã§åŠçããŸãã ãã ãã
Nokia 2 Androidã¹ããŒããã©ã³ã§ã¯ãåæ§ã®æ°å€ã190ããªç§ã«æ¡å€§ããŸãã ããã¯éåžžã«å°ãããšèšã£ãŠããããã§ã¯ãããŸãããããããã«ããŠããããŒãžã¯ååã«ãã°ããã€ã³ã¿ã©ã¯ãã£ãã«ãªããŸãã
ããŠãéèŠãªè³ªåã§ãã ã·ã³ãã«ãªNokia 2ã¹ããŒããã©ã³ã¯ãå¹³åçãªçŸä»£ã®ããŒãžãã©ã®ããã«ç®¡çããŠããŸããïŒ å®éãã²ã©ãã§ãã JavaScriptã³ãŒããããŒããããããŒãžã§ã®äœæ¥ã¯ãããªãã®æéãçµéããåŸã«ã®ã¿å¯èœã«ãªããããé«éã€ã³ã¿ãŒãããæ¥ç¶ã§ãã£ãŠãWebããŒãžãé²èŠ§ãããšããŠãŒã¶ãŒã¯å¿èãå¿
èŠãšããŸãã
åŠçãã¡ã€ã³ã¹ã¬ããããããã¯ãã倧éã®JSã³ãŒããå«ãããŒãžã衚瀺ãããšãã®Nokia 2ã®ããã©ãŒãã³ã¹ã®æŠèŠWebããŒãžã®é²èŠ§ã«äœ¿çšããããã€ã¹ãšããŒã¿ãéä¿¡ããããããã¯ãŒã¯ã¯è¿å¹Žå€§å¹
ã«æ¹åãããŸãããããããã®æ¹åã¯ãã¹ãŠãããŒãžã«å«ãŸãã倧éã®JSã³ãŒãã«ãã£ãŠãé£ãå°œãããããããšã瀺ãããŠããŸãã JavaScriptã責任ãæã£ãŠäœ¿çšããå¿
èŠããããŸãã 責任ã¯ãç§ãã¡ãäœæããŠãããã®ãšãã®æ¹æ³ãç解ããããšããå§ãŸããŸãã
ããµã€ãããšãã¢ããªã±ãŒã·ã§ã³ãã®ã€ããªãã®ãŒã®æ¯èŒ
å¥åŠãªããšã¯ãç§ãã¡ãäœããåŒã¶ããã«äœ¿çšããäžæ£ç¢ºãªçšèªã§èµ·ãããŸããããã®æå³ã¯çŽæçãªã¬ãã«ã§ã¯èª°ã§ãç解ã§ããŸãã ãããããšã¹ãºã¡ããã®éãã¯éåžžã«éèŠã§ããããããããšããèšèã®æå³ãããããããããšåŒãã§ããŸãã ãã®ãããªéããèæ
®ãããšããããããšããããã®è¡åãç°ãªããšããäºå®ã«ã€ãªããå¯èœæ§ããããŸãã ããšãã°ãç§ãã¡ã¯ã¹ãºã¡ããã®å·£ãç Žå£ããŸãããããã«ã€ããŠè©±ããŠããå Žåãæè«ã¯ã¯ããã«æçšã§è匱ã§ããééã£ãå Žæã«ããå·£ã¯ããããç Žå£ãããã©ããã«ç§»ãããšã«æ±ºããŸãã
ããŠã§ããµã€ããããã³ããŠã§ãã¢ããªã±ãŒã·ã§ã³ããšããçšèªã®äœ¿çšæ¹æ³ã«ãåæ§ã®èªç±ãèŠãããŸãã ãããã®æŠå¿µã®éãã¯ãå®éã®ãããšããããã®éãã»ã©æçœã§ã¯ãããŸãããããããã®æŠå¿µãçµã¿åããããšãéåžžã«äžå¿«ãªçµæã«ã€ãªããå¯èœæ§ããããŸãã ç¹å®ã®ãããžã§ã¯ãããåãªãWebãµã€ããã§ããããæ¬æ ŒçãªWebã¢ããªã±ãŒã·ã§ã³ãã§ãããã«å¿ããŠãäœããèš±å¯ãããšãã©ãã«ãå§ãŸããŸãã äŒç€Ÿã®æ
å ±ãµã€ããäœæããå ŽåãDOMã®å€æŽã管çããããã¯ã©ã€ã¢ã³ãã«ã«ãŒãã£ã³ã°ãå®è£
ãããããããã®åŒ·åãªãã¬ãŒã ã¯ãŒã¯ã«äŸåããããšã¯ã»ãšãã©ãªãã§ãããã å°ãªããšããããé¡ã£ãŠããŸãã ç¹å®ã®åé¡ã解決ããã®ã«ããŸãé©ããŠããªãããŒã«ã䜿çšãããšããµã€ãã䜿çšãã人ã
ã«å®³ãäžããã ãã§ãªããããããéçºããã»ã¹ã«æªåœ±é¿ãäžããå¯èœæ§ããããŸãã
Webã¢ããªã±ãŒã·ã§ã³ãéçºãããšãããã¹ãŠãç°ãªã£ãŠèŠããŸãã ããã±ãŒãžãã€ã³ã¹ããŒã«ããŸããããã«ã¯ããããžã§ã¯ãã«æ°åã§ã¯ãªãã«ããŠãæ°çŸãã®äŸåé¢ä¿ãè¿œå ãããŸãã ããã«ãç§ãã¡ã¯ããã
ã®ããã€ãã®
å®å
šæ§ã«ã€ããŠãã確信ããããŸããã ãã³ãã©ãŒã®è€éãªæ§æãèšè¿°ããŸãã ãã®ãããªãŠããã¿ã¹ãªã¯ã¬ã€ãžãŒãªéçºç°å¢ã§äœæ¥ããå Žåãåéããããã®ãé«éã§ããããããžã§ã¯ããæ©èœããã¯ãã®å Žæã§æ©èœããããã«ããããã«ãç¥èãšæ³šæãå¿
èŠã§ãã çãããå Žåã¯ããããžã§ã¯ãã®ã«ãŒããã£ã¬ã¯ããªã§
npm ls --prodã³ãã³ããå®è¡ãããã®ã³ãã³ãã衚瀺ãã
ãã¹ãŠã䜿çšããç®çã«ååãä»ãããããã©ããã確èªããŸãã ããšããããã§ãããšããŠããããã¯ãµãŒãããŒãã£ã®ã¹ã¯ãªããã«ã¯é©çšãããŸããã ãã®ãããªã¹ã¯ãªãããããã€ããããžã§ã¯ãã§äœ¿çšãããŠãããšç¢ºä¿¡ããŠããŸãã
Webãµã€ããšWebã¢ããªã±ãŒã·ã§ã³ã®äž¡æ¹ãåããçæ
åŠçãããããå ããããšãå¿ããŠããŸãã äž¡æ¹ãšããããŸããŸãªãããã¯ãŒã¯ãšããã€ã¹ã§æ§æãããç°å¢ã®åã圱é¿äžã«ãããŸãã ãã¢ããªã±ãŒã·ã§ã³ããéçºããŠãããã®ãšåŒã¶ããšã«ããå Žåããã®ãããªå¶éã¯ãªããªããŸããããŸããããµã€ããããã¢ããªã±ãŒã·ã§ã³ããšåŒã¶å ŽåããŠãŒã¶ãŒã®ããã€ã¹ãéæ³ã®ããã«éããªãããšã¯ãããŸããã
ç§ãã¡ãäœæãããã®ã誰ã䜿çšããããèŠã€ããã®ã¯ç§ãã¡ã®è²¬ä»»ã§ãããç°ãªããŠãŒã¶ãŒãã€ã³ã¿ãŒãããã«æ¥ç¶ããæ¡ä»¶ã¯ç§ãã¡ãäŸåããŠããæ¡ä»¶ãšã¯ç°ãªãå¯èœæ§ããããšããäºå®ãèæ
®ããå¿
èŠããããŸãã äœããäœæãããšããç§ãã¡ã¯ãããäœæããããã®ç®æšãç¥ãå¿
èŠãããããã®åŸã§ã®ã¿ããã®ç®æšãéæããã®ã«åœ¹ç«ã€ãã®ãéçºããå¿
èŠããããŸã-éçºã
ããã»ã©ãšããµã€ãã£ã³ã°ãªä»äºã§ã¯ãªããšå€æããå Žåã§ãã
ããã¯ãJavaScriptãžã®äŸåãåè©äŸ¡ããå¿
èŠãããããšãæå³ããç¹ã«HTMLãšCSSãæãªãJavaScriptã®äœ¿çšããWebãããžã§ã¯ãã®ããã©ãŒãã³ã¹ãšã¢ã¯ã»ã·ããªãã£ãæãªãäžåçãªãã¿ãŒã³ã®äœ¿çšã«ã€ãªããå¯èœæ§ãããããšãæå³ããŸãã
ãã¬ãŒã ã¯ãŒã¯ã«äžåçãªãã¿ãŒã³ã課ãããªãã§ãã ãã
ãã¬ãŒã ã¯ãŒã¯åºæã®ããŒã ãšååããŠçç£æ§ãåäžããããšãã«ãã³ãŒãããŒã¹ã§å¥åŠãªããšãçºèŠãããŸããã ãããã®çºèŠã®å€ãã«ã¯å
±éç¹ã1ã€ãããŸããããã¯ããããã®èšè¿°æ¹æ³ããµã€ãã®å¯çšæ§ãšããã©ãŒãã³ã¹ã®åé¡ã«ã€ãªããããšãå€ããšããããšã§ãã ããšãã°ã次ã®Reactã³ã³ããŒãã³ããèããŸãã
import React, { Component } from "react"; import { validateEmail } from "helpers/validation"; class SignupForm extends Component { constructor (props) { this.handleSubmit = this.handleSubmit.bind(this); this.updateEmail = this.updateEmail.bind(this); this.state.email = ""; } updateEmail (event) { this.setState({ email: event.target.value }); } handleSubmit () {
ããã§ã¯ããããžã§ã¯ãã®ã¢ã¯ã»ã·ããªãã£ã«é¢ããããã€ãã®æ³šç®ãã¹ãåé¡ãèŠã€ããããšãã§ããŸãã
<form>
èŠçŽ ã䜿çšããªã<form>
ã¯ããã¯ããã©ãŒã ã§ã¯ãããŸããã å®éã芪<div>
èŠçŽ ã®role = "form"ãæå®ããã ãã§ãããä¿®æ£ã§ããŸããããã©ãŒã ãäœæãã衚瀺ããããã®ããã©ãŒã ã®ããã«èŠããå Žåã¯ã <form>
èŠçŽ ã䜿çšããŠãããã«å¿ããŠèšå®ããŸãå±æ§action
ããã³method
ã action
å±æ§ã¯ããã§éèŠãªåœ¹å²ãæãããŸããããã¯ãJavaScriptã䜿çšã§ããªãå Žåã§ãïŒåœç¶ãã³ã³ããŒãã³ãããµãŒããŒã§ã¬ã³ããªã³ã°ãããå Žåã§ãïŒãã©ãŒã ãå°ãªããšãäœããå®è¡ã§ããããã«ããããã§ãã<span>
ã <label>
代ããã§<span>
ãŸãããããã¯ã <span>
ã¯ãªããããžã§ã¯ãã®å¯çšæ§ã«é¢ããæ©èœãæäŸããŸããtype="submit"
å±æ§ã®ãªã<button>
èŠçŽ ã¯åãªããã¿ã³ã§ããããããã¯ãªãã¯ãããšãããã«ãã€ã³ããããã€ãã³ããã³ãã©ãåŒã³åºãããŸãã ãã©ãŒã ãéä¿¡ããåã«ããŒã¿ãåŠçããå Žåã¯ããã¿ã³ã«type="submit"
å±æ§ãå²ãåœãŠã onClick
ã€ãã³ããã³ãã©ãŒããonSubmit
ãã©ãŒã ã€ãã³ããã³ãã©ãŒã«ã³ãŒãã移åããå¿
èŠããããŸãã- ãšããã§ãJavaScriptã䜿çšããŠé»åã¡ãŒã«ã¢ãã¬ã¹ãæ€èšŒããã®ã«å¯ŸããHTML5ã§ã¯ãã»ãšãã©ãã¹ãŠã®ãã©ãŠã¶ãŒïŒIE10ãŸã§ïŒã§å
¥åããŒã¿ã®ãã§ãã¯ããµããŒãããã³ã³ãããŒã«ãèªç±ã«äœ¿çšã§ããŸãã ããã§ã¯ããã©ãŠã¶ã«ãã§ã«ããæ©èœãå©çšããŠãé©åãªèŠçŽ ã¿ã€ããšå¿
é å±æ§ãé©çšããæ©äŒãéããŠããŸãã ãã ãããã®ãããªæ§é ã䜿çšããå Žåã¯ãã¹ã¯ãªãŒã³ãªãŒããŒãšã®éåžžã®å¯Ÿè©±ãèšå®ããã«ã¯å€å°ã®åŽåãå¿
èŠã«ãªãããšã«æ³šæããŠãã ããã
äžèšãèæ
®ããŠãã³ã³ããŒãã³ãã³ãŒãããªãã¡ã¯ã¿ãªã³ã°ããŸãã
import React, { Component } from "react"; class SignupForm extends Component { constructor (props) { this.handleSubmit = this.handleSubmit.bind(this); } handleSubmit (event) {
çŸåšããã®ã³ã³ããŒãã³ããã¬ã³ããªã³ã°ããããšããäºå®ã¯ãããã¢ã¯ã»ã¹ããããã ãã§ãªãã以åãšåãæ©èœãå®è£
ããããã«äœ¿çšãããJSã³ãŒããå°ãªããªã£ãŠããããšãããããŸããã JavaScriptã§æåéãdrããŠããäžçã§ã¯ãæ°è¡ã®ã³ãŒããåé€ããããšã¯ååããªãã®ãšèŠãªãããã¹ãã§ãã ãã©ãŠã¶ã¯
å€ãã®æ©äŒãäžããŠãããã®ã§ãã§ããã ãé »ç¹ã«ãããã®æ©äŒãå©çšããããåªåããå¿
èŠããããŸãã
ããã§ã¯ãç¹å®ã®ãã¬ãŒã ã¯ãŒã¯ã䜿çšããå Žåã«ã®ã¿ããŒãžã®ã¢ã¯ã»ã·ããªãã£ã«é¢ããåé¡ãçºçãããšã¯èšããããããŸããã ã€ãŸããéçºè
ã¯JavaScriptã«é ŒããããŠãå€ãã®éèŠãªHTMLããã³CSSæ©èœãåçŽã«èŠéããŠããŸããŸãã ç¥èã®ãããã®ã®ã£ããã¯ãã°ãã°ãšã©ãŒã«ã€ãªãããããã«ããããã®ãšã©ãŒãçãããšãããããŸããã ãã¬ãŒã ã¯ãŒã¯ã¯ãéçºè
ã®çç£æ§ãåäžããã䟿å©ãªããŒã«ã«ãªããŸãããéçºã§äœ¿çšãããè£å©ããŒã«ã«é¢ä¿ãªããåºæ¬çãªWebãã¯ãããžãŒã®æ©èœãåžžã«ç 究ããããšã¯ã䟿å©ã§äœ¿ãããã補åãäœæããäžã§éåžžã«éèŠã§ãã
Webãã©ãããã©ãŒã ã®åã«é Œã£ãŠããããžã§ã¯ãã«æããæªæ¥ãäžããŸããã
ãã¬ãŒã ã¯ãŒã¯ã«ã€ããŠè©±ããŠããã®ã§ãWebãã©ãããã©ãŒã èªäœã巚倧ãªãã¬ãŒã ã¯ãŒã¯ã§ããããšã«æ³šæããŠãã ããã åã®ã»ã¯ã·ã§ã³ã§ç€ºããããã«ãããŒã¯ã¢ããã䜿çšãã確ç«ããããã¿ãŒã³ãšãã©ãŠã¶ãŒã®æ©èœã«äŸåã§ããå Žåãããè¯ãç«å Žã«ãããŸãã ãããã®æšæºæ©èœã®ä»£æ¿æ段ã¯ãããããå床çºæããããšã§ãã èšããŸã§ããªãããã®ãããªãçºæãã«ã¯ããªãã®å°é£ã䌎ããŸãã ãããããã®ãããªåé¡ãããããç¬èªã®æ¹æ³ã§ãã€ã³ã¹ããŒã«ãããã¹ãŠã®JavaScriptããã±ãŒãžã®äœæè
ã«ãã£ãŠè§£æ±ºããããšãããã©ãã§ããããã
âã·ã³ã°ã«ããŒãžã¢ããªã±ãŒã·ã§ã³
ç°¡åã«è³Œå
¥ã§ããéçºè
ã®åŒ±ç¹ã®1ã€ã¯ããã®ã¢ãã«ãé©ããªããããžã§ã¯ãã§ããã·ã³ã°ã«ããŒãžã¢ããªã±ãŒã·ã§ã³ïŒSPAïŒã¢ãã«ã䜿çšããããšã§ãã ãã¡ããããã®ãããªãããžã§ã¯ãã¯ãã¯ã©ã€ã¢ã³ãã«ãã£ãŠå®è¡ãããã«ãŒãã£ã³ã°ã®ããã«ããŠãŒã¶ãŒã«ããçç£çã§ãããšèªèããããšããäºå®ã®æ©æµãåããŸãã ããããSPAã¢ãã«ã䜿çšããããšã®æ¬ ç¹ã¯äœã§ããïŒ ãã©ãŠã¶ã®çµã¿èŸŒã¿ããŒãžããã²ãŒã·ã§ã³æ©èœã¯ãåæã¢ãã«ã«åºã¥ããŠããŸããããããžã§ã¯ãã«å€ãã®å©ç¹ããããããŸãã ãããã®1ã€ã¯ã蚪åã®æŽå²ã®ç®¡çã
è€éãªä»æ§ã®å®è£
ãéããŠå®è¡ããããšããããšã§ãã JavaScriptãæããªããŠãŒã¶ãŒã¯ãJavaScript
ãç¡å¹ã«ãããã©ããã«é¢ä¿ãªã ããããžã§ã¯ããæäœããæ©èœã倱ãããšã¯ãããŸããã JavaScriptããªãã«ãããã©ãŠã¶ãŒã§1ããŒãžã®ã¢ããªã±ãŒã·ã§ã³ã䜿çšå¯èœã«ããã«ã¯ããµãŒããŒã®ã¬ã³ããªã³ã°ã«ããªãã®æ³šæãæãå¿
èŠãããããšãçªç¶å€æããŸããã
äœééä¿¡ãã£ãã«ã§å®éšã¢ããªã±ãŒã·ã§ã³ãããŒãããããã®ããŸããŸãªãªãã·ã§ã³ã®æ¯èŒã å·ŠåŽã®ã¢ããªã±ãŒã·ã§ã³ã®ã¬ã³ããªã³ã°ã¯ãJavaScriptã«å®å
šã«äŸåããŠããŸãã å³åŽã®ã¢ããªã±ãŒã·ã§ã³ã¯ãµãŒããŒäžã§ã¬ã³ããªã³ã°ãããŸãããã¯ã©ã€ã¢ã³ãäžã§hydrateïŒïŒã¡ãœããã䜿çšããŠããµãŒããŒäžã§æ¢ã«äœæãããããŒã¯ã¢ããã«ã³ã³ããŒãã³ããæ¥ç¶ããŸãããã§ã¯ãã¯ã©ã€ã¢ã³ãã§ã¬ã³ããªã³ã°ãããã¢ããªã±ãŒã·ã§ã³ãæ°ç§éãŠãŒã¶ãŒã«ç©ºçœã®ç»é¢ã衚瀺ããå®æããã€ã³ã¿ãŒãã§ã€ã¹ã衚瀺ããããšãããããŸãã
ãµãŒããŒã§ã¬ã³ããªã³ã°ãããã¯ã©ã€ã¢ã³ãã§åäœå¯èœã«ã¬ã³ããªã³ã°ãããã¢ããªã±ãŒã·ã§ã³ã¯ãã¡ã€ã³ã®ã€ã³ã¿ãŒãã§ãŒã¹èŠçŽ ããã°ãã衚瀺ããŸãããã¯ã©ã€ã¢ã³ãã§å®å
šã«ã¬ã³ããªã³ã°ãããã¢ããªã±ãŒã·ã§ã³ãšã»ãŒåãæéåŸã«äœ¿çšã§ããŸãã
ã¯ã©ã€ã¢ã³ãã«ããã«ãŒã¿ãŒãããŠãŒã¶ãŒã衚瀺ããŠããããŒãžã®å€æŽããŠãŒã¶ãŒã«éç¥ã§ããªãå Žåããã¢ããªã±ãŒã·ã§ã³ã®å¯çšæ§ãäœäžããŸãã ããã«ããããŠãŒã¶ãŒã¯æ¯æŽæè¡ã«é Œã£ãŠããŒãžäžã®æ£ç¢ºãªå€æŽãèŠã€ããããšãã§ãããã®çµæããµã€ãã§ã®ãŠãŒã¶ãŒã®äœæ¥ã¯ã¯ããã«è€éã«ãªããŸãã
ããã«ãã·ã¹ãã ã®éå°ãªè² è·ã§ããå€ãæµã«ããã«åºäŒãããšãã§ããŸãã äžéšã®ã¯ã©ã€ã¢ã³ãã«ãŒã¿ãŒã¯éåžžã«å°ããã§ãã ãã ãã
Reactã§ãããžã§ã¯ããäœæããäºææ§ã®ãã
ã«ãŒã¿ãŒã䜿çšããå Žåã«ãã£ãŠã¯ã¢ããªã±ãŒã·ã§ã³ã®ç¶æ
ã管çãã
ã©ã€ãã©ãªã䜿çšããå Žåãäžå®éã®ãµãŒãã¹ã³ãŒããå«ãŸããããšã«åæããå¿
èŠããããŸãã ã€ãŸãããã®å ŽåãçŽ135 Kbã®ã³ãŒãã§ãã äœæãããããžã§ã¯ããæ
éã«åæããã¯ã©ã€ã¢ã³ãã«ãŒãã£ã³ã°ãã·ã¹ãã ã®è¿œå è² è·ã«èŠåããã©ãããåæããŸãã éåžžãã¯ã©ã€ã¢ã³ãã«ãŒãã£ã³ã°ã·ã¹ãã ãæåŠããæ¹ãè¯ãããšããããŸãã
ãŠãŒã¶ãŒã®æ°æã¡ãå¿é
ããŠããå Žåããµã€ããé«éã«èŠãããå Žåã¯ã
rel = prefetch linkå±æ§ã䜿çšã§ããŸããããã«ãããåããœãŒã¹ããã®ããã¥ã¡ã³ãã®ããªããŒããæŽçã§ããŸãã ãã®å±æ§ã䜿çšãããšããŠãŒã¶ãŒãèªèãããããžã§ã¯ãã®ããã©ãŒãã³ã¹ã®åäžã«å€§ããªåœ±é¿ãäžããŸãããããã®ãªã³ã¯ãã¯ãªãã¯ãããšããã®å±æ§ã®äœ¿çšã«ãªã³ã¯ãããããŒãžããã£ãã·ã¥ããå³åº§ã«ããŒããããããã§ãã ããã«ãããŒã¿ã®ããªããŒãã®åªå
床ãäœãããã垯åå¹
ãããã£ãŠéèŠãªãªãœãŒã¹ãšç«¶åããããšã¯ã»ãšãã©ãããŸããã
/ãèšè¿°ããããšã«ãã£ãŠåç
§ãããHTMLã³ãŒãã¯ããµã€ãã®ã¡ã€ã³ããŒãžã«ã¢ã¯ã»ã¹ãããšãã«ããªããŒããããŸãã ãŠãŒã¶ãŒã察å¿ãããªã³ã¯ãã¯ãªãã¯ãããšãHTMLã³ãŒãããã©ãŠã¶ãŒãã£ãã·ã¥ããå³åº§ã«ããŒããããŸããããŒãžã®ããªããŒãã§çºçããå¯èœæ§ãããã泚æããå¿
èŠãããäž»ãªåé¡ã¯ããã®ãããªããŒããæéãšãªãœãŒã¹ã®ç¡é§ã«ãªãå¯èœæ§ãããããšã§ãã ããã解決ããã«ã¯ãããšãã°ãGoogleã®å°ããª
Quicklinkã¹ã¯ãªããã䜿çšããŠããã®åé¡ã軜æžã§ããŸãã çŸåšã®ã¯ã©ã€ã¢ã³ããäœéæ¥ç¶ã䜿çšããŠãããã©ããã
ããŒã¿ä¿åã¢ãŒããæå¹ã«ãªã£ãŠãããã©ããããã§ãã¯ããããã©ã«ãã§ã¯ãããŒãžãœãŒã¹ä»¥å€ã®ãœãŒã¹ããã®çŽ æã®ããªããŒããåé¿ã§ããŸãã
äœåºŠãã¢ã¯ã»ã¹ãããŠãŒã¶ãŒã®ç®ã«ã¯ãµã€ãã®èŠãç®ãéãããããã«ã
Service Workerã䜿çšã§ããŸãã ãµãŒãã¹ã¯ãŒã«ãŒã®
æ©èœã®äžéšã«ç²ŸéããŠããå Žåã¯ããããžã§ã¯ãã§ã¯ã©ã€ã¢ã³ãã«ãŒãã£ã³ã°ã·ã¹ãã ã䜿çšãããã©ããã«é¢ä¿ãªã䜿çšã§ããŸãã ãµãŒãã¹ã¯ãŒã«ãŒã
䜿çšããŠã«ãŒããã£ãã·ã³ã°ãå®è¡ãããšãäžéšã®ãªã³ã¯ã®çŽ æãããªããŒãããå Žåã«éåžžèŠãããã®ãšåãå©ç¹ãå€æ°åŸãããŸããããªã¯ãšã¹ããšåçãåŠçããæ©äŒã¯ã¯ããã«å€ããããŸãã ãµã€ãããã¢ããªã±ãŒã·ã§ã³ããšããŠèªèãããã©ããã«ãããããããµãŒãã¹ã¯ãŒã«ãŒãè£
åããããšã¯ãããããæãéèŠãªJavaScriptã®äœ¿çšäŸã®1ã€ã§ãã
âJavaScriptã¯ã¬ã€ã¢ãŠãçšã«èšèšãããŠããŸãã
ããŒãžã¬ã€ã¢ãŠãã«é¢é£ããåé¡ã解決ããããã«èšèšãããJSããã±ãŒãžãã€ã³ã¹ããŒã«ããå Žåã¯ããã®ããã±ãŒãžã§äœãéæããããšããŠããã®ããæ
éã«ç¢ºèªããå¿
èŠããããŸãã CSSã¯ãããŒãžã¬ã€ã¢ãŠããæ§ç¯ããããã«
ç¹å¥ã«äœæããã
ãã®ã§ãå¹æçã«äœ¿çšããããã«æœè±¡åã¯å¿
èŠãããŸããã JavaScriptã䜿çšããŠè§£æ±ºããããšããèŠçŽ ã®
é
眮ãèŠçŽ ã®
é
眮 ããµã€ãºã®èª¿æŽïŒ
ããã¹ãã®ç®¡çãªã©ïŒã JavaScriptã䜿çš
ããã¬ã€ã¢ãŠãã®å®å
šãª
äœæãªã©ãã¬ã€ã¢ãŠããæ§ç¯ããã¿ã¹ã¯ã®ã»ãšãã©ã¯ãCSSã䜿çšããŠè§£æ±ºã§ããããã«ãªããŸããã FlexboxãGridãªã©ã®ã¬ã€ã¢ãŠããäœæããããã®ææ°ã®ããŒã«ã¯ãã©ãŠã¶ã§ååã«ãµããŒããããŠãããããã¬ã€ã¢ãŠããæäœããããã®ãã¬ãŒã ã¯ãŒã¯ã«åºã¥ããŠãããžã§ã¯ããéçºããå¿
èŠã¯ãããŸããã ãšããã§ãCSSã¯ãã¬ãŒã ã¯ãŒã¯ã§ããããŸãã ç§ãã¡ãèªç±ã«
ããããã£ãªã¯ãšã¹ããªã©ã®æ©äŒãããå Žåãã¬ã€ã¢ãŠãã®æ°ããæ¹åæ段ããµããŒãããããã®ã¬ã€ã¢ãŠãã®é²æ©çãªæ¹åã¯ãçµå±ã®ãšãã
ããã»ã©é£ãããã
ãŸãã ã
/* , , , CSS Grid. */ /* @supports , CSS Grid, . */ @supports (display: grid) { /* */ @media (min-width: 40em) { /* CSS Grid */ } }
JavaScriptã䜿çšããŠããŒãžã¬ã€ã¢ãŠããäœæãããã®å€èŠ³ãã«ã¹ã¿ãã€ãºããåé¡ã解決ããããšã¯ããã¥ãŒã¹ã§ã¯ãããŸããã ããã¯ããã¹ãŠã®ãµã€ããåœæã®ããé«åºŠãªãã©ãŠã¶ãŒãšåãããã«IE6ã®ããã«èŠããã¹ãã ãšèšã£ãŠã2009幎ã«ç§ãã¡ãèªå·±æ¬ºliveã®é°å²æ°ã«äœãã§ããããšã§ãã ä»æ¥ã2019幎ã«ããã¹ãŠã®ãã©ãŠã¶ãŒã§åãããã«èŠããããã«ãµã€ããéçºãç¶ããå Žåãããã¯ç®æšãåèããå¿
èŠãããããšãæå³ããŸãã ãµããŒããå¿
èŠãªãã©ãŠã¶ã¯åžžã«ååšããææ°ã®ãã©ãŠã¶ãšåãæ©èœãåããŠããŸããã ãã¹ãŠã®ãã©ãããã©ãŒã ã§ã®ãããžã§ã¯ãã®å®å
šãªå€éšé¡äŒŒæ§ã¯ããšãã«ã®ãŒã®æµªè²»ã§ããã ãã§ãªãã
é²æ©çãªæ¹åã®ã¢ã€ãã¢ã®äž»èŠãªæµã§ããããŸãã
çµè«ïŒJavaScriptãã©ãŒã«ãªãã€ããã¯ãããŸãã
誀解ããªãã§ãã ãããç§ã¯JavaScriptã®æµã«å±ããŠããŸããã ãã®èšèªã®ãããã§ãç§ã¯ãã£ãªã¢ãç¯ãäžããŸããããããŠãççŽã«èšã£ãŠãJavaScriptã¯10幎以äžã«ããã£ãŠç§ã«å€ãã®åã³ããããããŠããŸãã é·æçãªé¢ä¿ã®å Žåãšåæ§ã«ãJavaScriptã䜿çšããæéãé·ããªãã°ãªãã»ã©ãJavaScriptãããããç¥ãããšãã§ããŸãã ããã¯ãå€ãã®æ©èœãåããæçããèšèªã§ãããæ¯å¹Žæ¹åãããŠããŸãã
ãã ããJavaScriptã®é¢ä¿ã«äœãåé¡ãããããã«æããå ŽåããããŸãã ç§ã¯åœŒãæ¹å€ããŸãã ãŸãã¯ãããæ£ç¢ºã«ã¯ãJavaScriptãäž»ã«ä»ã®ããšãèŠãããšãªã䜿çšãããã¡ã€ã³ã®ãµã€ãæ§ç¯ããŒã«ãšèŠãªãçŸåšã®åŸåãæ¹å€ããŸãã çŽããããã¯ãªã¹ãã¹ã¬ãŒã©ã³ãã®ããã«èŠããå¥ã®ãã³ãã«ãåæãããšããŠã§ããJavaScriptã«å€¢äžã«ãªã£ãŠããããšãæããã«ãªããŸããã ç¶æ³ããããå¿
èŠãšããªãå Žåã§ãã£ãŠããã»ãšãã©ãã¹ãŠã®çç±ã§ãã®èšèªã«é ŒããŸãã æã
ãç§ã¯JSã«å¯Ÿãããã®æ
床ã®çµæãã©ãã»ã©æ·±å»ã§ãããã«ã€ããŠèããŸãã
ç§ã¯JavaScriptãšWebéçºã«ã€ããŠæžãç¶ããWebãã¯ãããžãŒãåççã«äœ¿çšããæ¹æ³ãæ¢ãç¶ããã€ããã§ãã ããŸãããã°ãç§ãã¡ã¯çŸä»£ã®ãŠã§ããããè¯ãããããšãé¡ã£ãŠããŸãã
芪æãªãèªè
ïŒ ææ°ã®ãŠã§ãã¯æ¬åœã«JavaScriptã³ãŒãã§ãªãŒããŒããŒããããŠãããšæããŸããïŒ