What would more ideal to detect a page protocol so as to access an external file via http. Due to security url's containing http will not work on a page with https. The call is for external JS file. Would it be more ideal to detect this in a JS conditional or go through a server side code to determine this before the page loads.
Thank you in advance.
You simply omit the http:
and turn the URL into a Protocol Relative URL and it will work without any extra code:
.ajax({ url: "//external.com/js/external.js" })
More info:
How to Include CSS and JS files via HTTPS when needed?
and here:
https://blog.httpwatch.com/2010/02/10/using-protocol-relative-urls-to-switch-between-http-and-https/
http://billpatrianakos.me/blog/2013/04/18/protocol-relative-urls/
http://support.volusion.com/article/resolving-unsecured-content-secure-pages