æ¦è¦
Google Chromeã使ã£ã¦ãdocument.write()ã§å¤é¨ã®JavaScriptãèªã¿è¾¼ãã§ãããã¼ã¸ãéãã¨ããã¤ã®éã«ãéçºè ãã¼ã«ã®ã³ã³ã½ã¼ã«ã«ä»¥ä¸ã®ãããªã¡ãã»ã¼ã¸ãåºãç¶æ ã«ãªã£ã¦ãã
"A Parser-blocking, cross-origin script, ã¹ã¯ãªããã®URL, is invoked via document.write. This may be blocked by the browser if the device has poor network connectivity."
éçºè
ãã¼ã«ãéããªããé©å½ãªãµã¤ããè¦ã¦ããã¨ãåºåã£ã½ãURLãå¼ã£ããã£ã¦ããã¨ãå¤ã
ãã®è¦åãä½ãæå³ãã¦ãããã¨ããã¨ãé ãæºå¸¯é»è©±ã®éä¿¡ã ã¨ãã¼ã¸ã®èªã¿è¾¼ã¿ãé ããªãã®ã§ã以ä¸ã®ããã«document.write()ã§ã¯ãã¹ãªãªã¸ã³ã®ã¹ã¯ãªãããèªã¿è¾¼ãã§ãChromeã§å®è¡ãããªããªãå¤æ´ãå ¥ãããã(ä»ã¯ã¾ã è¦åã ãã§å®éã«ãããã¯ãããã®ã¯2016å¹´10æãã)
document.write('<script src="ã¹ã¯ãªããã®URL"></script>');
詳細ã¯ä»¥ä¸ã®ããã¥ã¡ã³ãã«æ¸ããã¦ãããéè¦ãããªã¨ããã ã以ä¸ã«ã¡ã¢ãã
å®è¡ãããªããªãæ¡ä»¶
以ä¸ã®æ¡ä»¶ããã¹ã¦æºãããå ´åã¹ã¯ãªãããå®è¡ãããªããªã
- éä¿¡ãé ã(ä»ã¯æºå¸¯é»è©±ã®2Gã対象ãå°æ¥çã«ã¯é ã3Gãé ãWifiã«ãæ¡å¼µããããããããªãã¨ã®ãã¨)
- ãããã¬ãã«ã§ã®ããã¥ã¡ã³ãã§ã®document.write() (iframeã®ä¸ãªãã°åé¡ãªã)
- scriptã«asyncãdeferå±æ§ãæå®ããã¦ããªã
- ã¹ã¯ãªããããã£ãã·ã¥ããã¦ããªãå ´å (æ¢ã«ãã£ãã·ã¥ããã¦ããã°åé¡ãªã)
- ãªãã¼ãã§ã¯ãªã
è¦åã¡ãã»ã¼ã¸
Chromeã®ãã¼ã¸ã§ã³53(2016å¹´9æ)ãããã®è¦åãåºãããã«ãªã£ã
éä¿¡ã®é
ã以å¤ã®æ¡ä»¶ãæºãããã¨ãã«éçºè
ãã¼ã«ã«åºãããã«ãªã£ã¦ããããã
(ãªãã¼ãã§ãè¦åãåºã¦ãããããªæ°ããããã©â¦â¦)
ã¹ã¯ãªããã®ãããã¯
stableçã§ã10æåã°ããã(Chrome 54)ã«ãªã£ããå®éã«ã¹ã¯ãªãããåããªããããäºå®
We will intervene to block injected scripts for 2G users tentatively starting in Chrome 54, which is estimated to be in a stable release for all users in mid-October 2016.
https://developers.google.com/web/updates/2016/08/removing-document-write
対ç
åé¿çã¯document.write()ã使ãã®ãããã¦document.appendChild()ãparentNode.insertBefore()ãªã©ã使ãããã
ãã¨ã¯scriptã«asyncå±æ§ãdeferå±æ§ãä»ããã¨ããiframeã®ä¸ãªã©ã§ã¯åé¡ãªããããã®ã§ããã£ã¡ã«æ¸ãã¦ã¿ãã¨ãâ¦â¦
Interventionãããã¼
å®éã«ã¹ã¯ãªããããããã¯ãããå ´åãã¹ã¯ãªããã¸ã®GETãªã¯ã¨ã¹ãã®ã¨ãã«ä»¥ä¸ã®ãããªãããã¼ãéãããããã«ãªãããã(ä»ã¯ã¾ã éã£ã¦ãªãããï¼)
Intervention: https://shorturl/relevant/spec;
document.write()ã§ã¹ã¯ãªãããèªã¿è¾¼ãã§ãã¦å ´åã«ãã£ã¦ã¯ãããã¯ãããã¨ãã¯ä»¥ä¸ã®ãããã¼
Intervention: https://shorturl/relevant/spec; level="warning"
ã¾ã¨ã
10æåã°ãããããdocument.write()ã§å¤é¨ã®ã¹ã¯ãªãããèªã¿è¾¼ãã§ããã¨Chromeãå®è¡ãã¦ãããªããªããããããªãã®ã§æ³¨æã
ä»ã®ã¨ãã2G対象ãªã®ã§ãã¾ãå½±é¿ã¯ãªãããã ãã©ãå°æ¥çã«ã¯é
ã3Gãé
ãWifiã対象ã«ãªããããããªãã®ã§ãéçºè
ãã¼ã«ã§è¦åãåºã¦ããå ´åã«ã¯å¯¾çãããã»ãããããã
追è¨
ãã¤ã®ã¾ã«ãéçºè
ãã¼ã«ã«è¡¨ç¤ºãããã¡ãã»ã¼ã¸ã®æè¨ãå¤ãã£ã¦ãã
sucrose.hatenablog.com