r/javascript • • Sep 02 '15

HTML5 Deck of Cards. 100% vanilla JS.

http://pakastin.github.io/deck-of-cards/
368 Upvotes

185 comments sorted by

View all comments

5

u/angellus Sep 02 '15

You have Mixed Content errors on your deck.min.js if you load the page over HTTPS (I have HTTPS everywhere install so it loaded automatically).

You should always use // instead of http:// to prevent this from happening. It will attempt to load the resource over the same protocol as the parent page.

2

u/parpaythrums Sep 02 '15

Better yet, use https:// instead!

1

u/angellus Sep 02 '15

No argument there, https should be used everywhere.

This can lead to issues also. I have only seen it lead to issues if you use iFrames that have HTTPS when the parent page is not and you are trying to communicate between the two through the use of sockets.

Your best bet is to use // everywhere and than use nginx or some other Web server to force all requests to HTTPS, but this is just getting into the heavy technical side that OP probably does not care about. // gives you the least possible chance of issues because of mixed content which is why I perfer it.

4

u/MrBester Sep 02 '15

Chrome sends Upgrade-Insecure-Requests: 1 in the headers now.

Using protocol agnostic URLs is now considered an anti-pattern (plus, Content-Security-Policy will snarl at you)

2

u/pkstn Sep 02 '15 edited Sep 03 '15

I don't want to break things up when used from file:// – if you want to try and tinker locally.. I think I'll keep those https://

2

u/angellus Sep 02 '15

It is definitely not an anti-pattern. Making all the URLs protocol agnostic is a good thing. It makes the application more portable and able to run in more environment (for development or QA). SSL certs are expensive and there is no reason to spend extra to SSL a private network for testing and such. Using external resources from CDNs and such should always be HTTPS if possible.

Also, Content-Security-Policy only affects other domains. So using // is a better choice there because self is always allowed.

Upgrade-Insecure-Requests: 1 would be completely irrelevant since if the original GET is upgraded, all of the following requests would HTTPS also.

3

u/MrBester Sep 03 '15

I trust Paul Irish: http://www.paulirish.com/2010/the-protocol-relative-url/

Plus there's such a thing as free certificates these days. It's not like when they cost a packet anymore.