How to include CSS and JS files via HTTPS

Generally we include the CSS and JS files are in the below format.
<link rel="stylesheet" href="http://example.com/style.css">  
<script src="http://example.com/script.js">
The links are works perfect in the normal protocal like http://example.com .when we move to the SSL enabled site i.e https://example.com.

In this case above inlcuded CSS and JS files are not works perfectly because of it use's the protocol relative paths.

To avoid these problem's load your CSS and JS files in the below format.
 <link rel="stylesheet" href="//example.com/style.css">  
<script src="//example.com/script.js"></script>
Then it will use the protocol of the parent page.
* If you like this post please don’t forget to subscribe Techies Badi - programming blog for more useful stuff


EmoticonEmoticon