define( 'WPCACHEHOME', '/srv/www/www.ichilton.co.uk/html/blog/wp-content/plugins/wp-super-cache/' ); //Added by WP-Cache Manager https | Ian Chilton

Archive

Posts Tagged ‘https’

Network Path Reference (Protocol Relative URL)

March 5th, 2011 No comments

Anyone who has done web development on a site that uses a https:// (SSL) secure connection will be familiar with the annoying “This Page Contains Both Secure and Non-Secure Items” error (or exclamation mark in other browsers) if you include an asset in http:// on the page.

This neat trick, which Paul Irish calls the “Protocol Relative URL”.

If you use // at the beginning of the URL, it will automatically use whichever protocol you are currently using.

eg:

<img src="//domain.com/images/logo.png">
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.js"></script>
.myclass { background: url(//domain.com/images/background.gif);

The only cavet is that you should avoid using it with <link> or @import to include stylesheets as IE7 and IE8 have a bug where it will load the stylesheet twice, which is in-efficient (especially since downloading a stylesheet is a blocking action so it will halt rendering the page while it downloads).

Categories: Web Tags: , ,