A double slash in the URL path is valid and will respond in the browser, but is typically unwelcome, as this could cause duplicate content issues if the CMS delivers the same content on two URLs (i.e. single slash and double slash).
If the double slash in the page's permalink is generated by your CMS, you might need to address your developer for help. If the URL with a double slash is indexed in Google or has incoming external links, you can set the proper 301 redirects to the corrected URL.
The authority component is preceded by a double slash ("//") […] This is also why not all URIs contain the double slash: because not all URIs have an authority component (e.g., URIs using the mailto scheme, the xmpp scheme, etc.).
// The double slashes tell the browser not to render it. </ script> Also, you can do multiple line comments: <script type="text/javascript"> /* This is a multiple line comment! */ </script> As you can see, multiple line comments in JavaScript are very similar to CSS comments.
Best known as "protocol relative URLs", they are particularly useful when elements — such as the JS file in your example — could be loaded from either a http
or a https
context. By using protocol relative URLs, you can avoid implementing
if (window.location.protocol === 'http:') {
myResourceUrl = 'http://example.com/my-resource.js';
} else {
myResourceUrl = 'https://example.com/my-resource.js';
}
type of logic all over your codebase (assuming, of course, that the server at example.com
is able to serve resources via both http
and https
).
A prominent real-world example is the Magento E-Commerce engine: for performance reasons, the shop's pages use plain http
by default, whereas the checkout is https
enabled.
When hard-coded resources (i.e. promotional banners in the site's header) are referenced by non protocol relative URLs (i.e. http://example.com/banner.jpg
), customers reaching the https
enabled checkout will be greeted with a rather unfriendly
"there are insecure elements on this page"
prompt - which, as you can imagine, throws the average non-tech-savvy person off.
If the aforementioned resource is referenced via //example.com/banner.jpg
though, the browser takes care of prepending the proper protocol.
tl;dr: With even the slightest possibility of a mixed http/https environment, just use the double slash/protocol relative URLs for loading your resources — assuming that the host serving the content is both http and https enabled.
It will automatically add https or http, depending on how the request was made.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With