LoginSignup
8
4

More than 5 years have passed since last update.

ChromeでRiot.jsを実行した時、Javascriptコンソールに「Fetching scripts with an invalid type/language attributes is deprecated...」と表示される場合の対処法

Posted at

症状

Riot.jsを使用する際、次のような感じでHTMLに記載すると思います。

<script src="tags/autocomplete/ac.tag.html" type="riot/tag"></script>

しかし、これをChromeでテストすると、次のような警告がJavascriptコンソールに表示されます。

「Fetching scripts with an invalid type/language attributes is deprecated and will be removed in M56, around January 2017. See https://www.chromestatus.com/features/5760718284521472 for more details.」

エラー表示

原因

Chromeの仕様変更により、type="riot/tag"で指定されたソースの、ブラウザの機構を使った事前取得が拒否されるようになるためです。Riot.jsは、別途、Ajaxを使って参照先のソースを取得していますので、このメッセージを放置していたとしても、将来アプリが動かなくなる!ということはありません。

詳細な経緯は、以下のIssueを参照してください。
https://github.com/riot/riot/issues/2132

対処

放置していても無問題ですが、警告が気になって仕方のない場合は、Riot.jsを3.0.3以降にバージョンアップしてから、srcをdata-srcに変更すれば、警告が表示されなくなります。

<script data-src="tags/autocomplete/ac.tag.html" type="riot/tag"></script>

マニュアル:API · Compiler > riot.compile(callback)
http://riotjs.com/api/compiler/#a-namecompilea-riotcompilecallback

Compile all tags defined with <script type="riot/tag"> to JavaScript. These can be inlined script definitions or external resources that load scripts defined with src attribute (or data-src if you want to avoid the scripts prefetch in some browsers).

8
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
8
4