I have the following web page that redirects http
traffic to https
.
<head>
<script type="text/javascript">
var loc = window.location.href+'';
if (loc.indexOf('http://www.') == 0 && loc.indexOf('.com') > -1) {
window.location.href = loc.replace('http://www.','https://www.');
} else if (loc.indexOf('http://') == 0 && loc.indexOf('.com') > -1 && loc.indexOf('www.') == -1) {
window.location.href = loc.replace('http://','https://www.');
}
</script>
</head>
<body>
...
</body>
Question
I have placed the redirect javascript above the html body
. Does this mean that the page will get redirected before the body
tries to load?
I am trying to make this code as efficient as possible.
Any advise appreciated.