Protocol Relative Script SRC

posted in: Uncategorized | 0

So, I was going through Stack Overflow, answering some questions, when I came across something interesting I didn’t know before.

This:

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>

Is perfectly valid (assuming we’re on a web server and NOT on a local file system). It will call the script in question by the protocol (HTTP or HTTPS) to match the protocol of the current page.

So simple and yet so awesome.

Learn something new every day.

My name is Andrew McGivery. I currently work full time as an application developer at Manulife Financial in Canada. My current passion is building and leading highly engaged teams where employee happiness, learning, and growth is a priority.

Leave a Reply