27
23

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

CSSやJavascriptを読み込む時httpやhttpsを省略する

Posted at

最近になってCSSやJavascriptを読み込むときhttpやhttpsを省略できることを知ったので、
メモとして残しておこうと思います。

例えばgoogle mapsのJavascriptを読み込むとき

<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>

のように記述していたのですが、

<script type="text/javascript" src="//maps.google.com/maps/api/js?sensor=false"></script>

このようにhttpやhttpsを省略した形で記述できる。
省略した場合はhttpのページはhttpになるしhttpsのページならhttpsになります。
これは便利だと個人的には思います。
デメリットとかあるのだろうか

27
23
1

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
27
23

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?