# Can JS answers require the code to be run at a certain domain?

In challenges that require loading remote data - e.g. "What's my PPCG ID?" - some JavaScript (or other languages that may be run in the browser) answers may rely on being run at a certain domain (example answer), or may include extra code to safe-guard against being run at a certain domain (example robber).

Should answers be allowed to restrict which domains they can be run at? Should they be required to be runnable on all domains?

• We usually define a language by it's interpreter/compiler. In that case requiring a certain browser is fair play as not all support all the same features. Requiring to run on a certain domain is more at the execution level and so I'd say no. However, I'm not experienced enough to judge this properly. – TheLethalCoder Aug 8 '17 at 12:53
• Sometimes this is a requirement due to CORS – Downgoat Aug 20 '17 at 3:50

# Yes, as long as it isn't used to store data

We allow specific platform and environment requirements, as long as:

1. It is specified in the post
2. They aren't being used to store bytes (on or similar challenges where byte-count matters)

Requiring a particular domain is simply requiring a particular environment

• The environment usually matters for the languages implementation/compilation i.e. different C compilers and browser specific behaviour. I think requiring a domain is more at the code execution level than the environment level. – TheLethalCoder Aug 8 '17 at 14:54
• I think it boils down to the same as how we treat file names as @StepHen mentions in their answer. – TheLethalCoder Aug 8 '17 at 14:55
• @TheLethalCoder File paths aren't under different guidelines. If there was a challenge to "delete all files", assuming that you are in the / filepath is an environment requirement that is perfectly accceptable. – Nathan Merrill Aug 8 '17 at 14:59
• I suppose when you think of it that way it makes more sense... – TheLethalCoder Aug 8 '17 at 15:00
• I think it would help to address what storing data specifically consists of - for instance, does this answer: codegolf.stackexchange.com/a/138094/20080 use the domain to store data? I think it does. – isaacg Aug 12 '17 at 21:16
• @isaacg I'm not sure what I think of that issue, and I don't feel comfortable editing my answer. Something to consider, though: Let's say there was a challenge to read the hosts file: Would you allow the answer to assume that it was in the /etc directory? – Nathan Merrill Aug 13 '17 at 12:56

# For Code-Golf - domain would be extra bytes

This is mostly directed at , which I believe is not what you are asking about. However, if a answer requires a certain domain, it should be included in the byte count. This is exactly how we treat file names, for example.

• Was my thoughts as well just couldn't quite pin down why for an answer though. I forgot about requiring file names into the byte count so this is the correct answer. – TheLethalCoder Aug 8 '17 at 13:00
• Would answers that require the domain to not be a certain value (for whatever reason) be invalid? – Birjolaxew Aug 8 '17 at 13:04
• @Birjolaxew no. this just means that if your answer only works on a certain domain, you must include that domain in your byte count. If it works on any domain, just like if it works with any filename, you do not need to include it in the byte count. When using the filename to store data, add them as extra bytes to your solution similarly to any non-standard parameter. - from standard loopholes. – Stephen Aug 8 '17 at 13:07
• @StepHen But what if the answer works with all domains (or filenames) except one (e.g. the answer relies on cross-origin functionality, similar to the linked robber)? Would the answer be invalid unless code is included to ensure all domains work? – Birjolaxew Aug 8 '17 at 13:09
• @Birjolaxew oh, sorry, I misunderstood what you said the first time. I'm not sure. – Stephen Aug 8 '17 at 13:10
• Working on only a couple domains (or even 1) is perfectly fine as long as they aren't using the domain to store data. We allow any environment, no matter how specific, but draw the line when it is used to store data. – Nathan Merrill Aug 8 '17 at 13:12
• @NathanMerrill you may be correct - you probably should post an opposing answer, as that is not what my answer currently says. – Stephen Aug 8 '17 at 13:15

# No

In my opinion, this constitutes outsourcing the real answer, which is a standard loophole. This is because it outsources the fetching of data from the website to the browser that ran the code.

I'd like to address the two "yes" arguments that were presented by Nathan Merril:

1. It is specified in the post
2. They aren't being used to store bytes (on or similar challenges where byte-count matters)
1. This doesn't make much sense to me. If a question explicitly allows something, it can be allowed, but this Meta post is tagged as , which indicates that we are looking from a general consensus in absence of any specification by the OP.

2. The definition of "storing bytes" is a little bit sketchy here. Even if the environment is not being used to store program code, it could still be storing data, and it is indirectly saving bytes by removing the need for a GET request or similar to fetch the data from the website. The standard loopholes are there to tell us what bytes are acceptable to save.

I'll finish with the ever-so-popular advice on PPCG: golf your code, not your IO format. Allowing code run at a specific domain feels too much like golfing the IO format to me.

• If the was a challenge "delete all files", does that mean that users couldn't assume that the cwd is at /? – Nathan Merrill Oct 11 '17 at 12:15
• @NathanMerrill I think the OP could allow that, but it shouldn't be a default. And besides, that is outside the scope of this question. – Esolanging Fruit Oct 11 '17 at 15:22