Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why not always use https when including a js file?

For what reasons do sites provide logic to switch between http/https protocols for JavaScript include files? Why not always use https?

like image 313
Jones Avatar asked Apr 30 '10 16:04

Jones


3 Answers

HTTPS means :

  • You need a server configured properly
  • You need a certificate on your server
    • And, to not get a warning in the browser, you need a certificate signed by some trusted authority
    • And this costs a bit of money
  • A small bit of performance impact
    • The server has to crypt the data
    • The client has to de-crypt it
  • I would bet HTTPS means less caching
    • Maybe on the client side ?
    • And, most probably, on proxies ?

If you don't need HTTPS... Well, why use it ?

like image 114
Pascal MARTIN Avatar answered Oct 05 '22 22:10

Pascal MARTIN


There's less overhead if you just use http to serve the javascript include files. However, if you are running a site over https then you'll want to load everything over https, including the javascript include files.

like image 24
ChronoPositron Avatar answered Oct 05 '22 23:10

ChronoPositron


Because you can get the page both with and without SSL.

If you mix secure and unsecure requests in a page, the user will get a warning, so when the page is requested using https, it will have to requests the scripts using https also. This is usually done automatically when you request scripts from the same site with a relative URL, but if you have to use a complete URL to request a script from a different domain, the protocol has to be set dynamically.

like image 34
Guffa Avatar answered Oct 05 '22 23:10

Guffa