How to Include CSS and JS files via HTTPS when needed?

Use protocol-relative paths.

Thus not

<link rel="stylesheet" href="http://example.com/style.css">
<script src="http://example.com/script.js"></script>

but so

<link rel="stylesheet" href="https://example.com/style.css">
<script src="https://example.com/script.js"></script>

then it will use the protocol of the parent page.

Leave a Comment