2

I develope a plugin that is currently being used in thousands of websites. The code to install the plugin includes a reference to a javascript without the protocol, for example:

//www.mysite.com/js/script.js

This works fine on the majority of the websites, requesting from https or http version depending on the current protocol.

However, from time to time, let's 0,5%, there are websites that don't recognize this way of referencing a js script. When I look the website code I find:

http://www.userwebsite.com//www.mysite.com/js/script.js

This is not a browser specific issue, because I test it with any browser and I still have the issue.. it's more a website specific problem.

I've read everywhere that this is the recommended practice, and can't find the source of the problem. Any ideas?

- Most of the sites that use the plugin are WordPress sites
- The js reference is included directly into the HTML, inside the body
2
  • Do the websites that don't recognize the url have the same doctype as the others? Commented Jul 31, 2013 at 10:44
  • No, the one I'm looking now, has a <!DOCTYPE html>, the same as others, but this has the problem Commented Jul 31, 2013 at 10:47

1 Answer 1

2

If it's already in the website code (the HTML source) then it can't be a browser or JavaScript issue. As you already assumed correctly, it must be a server side problem.

Maybe the pages where your plugin is placed on are converting those links. And they don't recognize the double slashes so they think it's a relative url on the server hence prepending the protocol and domain.

Maybe they use some sort of code optimization / JavaScript minification that is changing your links.

Sign up to request clarification or add additional context in comments.

1 Comment

Sure... it must be a server problem. As you say, it is already in the HTML code. Thanks.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.