News for hackers. Stuff that matters.
Re:Run JavaScript on Cloudflare with Workers by kentonv on Tuesday March 13, 2018 @10:05AM (#16576165)
Same thing. Your site has only one worker script, and each request is therefore processed by at most one Worker. You can of course merge many independent pieces of logic into one script -- it's code, after all.

Enterprise customers are allowed to have multiple scripts mapped to different URL routes. This is mainly so that different teams owning different parts of the site don't step on each other. However, generally if you stuff your logic into one script rather than multiple, it will perform better, since that one script is more likely to be "hot" when needed.

Re:Run JavaScript on Cloudflare with Workers by netcraft on Tuesday March 13, 2018 @10:30AM (#16576373)
ohhh, its one worker per domain, you cant have different ones that match on url? so you have to do that matching in your worker to run different code?
Re:Run JavaScript on Cloudflare with Workers by elithrar on Tuesday March 13, 2018 @11:34AM (#16576965)
Note that Enterprise customers can have multiple scripts-per-domain, allowing you to run specify a specific script per route (or routes). Additional matching logic (e.g. headers, cookies, response codes) can then be done within the Worker itself.
Re:Run JavaScript on Cloudflare with Workers by kentonv on Tuesday March 13, 2018 @10:38AM (#16576448)
Correct.
Re:Run JavaScript on Cloudflare with Workers by btb on Tuesday March 13, 2018 @01:09PM (#16577670)
Hopefully that limitation can be relaxed over time. Having to stuff all my logic in one big script sounds a bit annoying. At minimum having access to a second worker script route would be welcome for testing/development purposes, so one doesn't muck up a working production script.
Re:Run JavaScript on Cloudflare with Workers by kentonv on Tuesday March 13, 2018 @01:17PM (#16577748)
> Having to stuff all my logic in one big script sounds a bit annoying.

Keep in mind that you can write your code as a bunch of modules and then use a tool like webpack to bundle it into one script, before you upload it to Cloudflare.

> for testing/development purposes

I agree with this, we definitely plan to add better ways to test script changes. Currently there is the online preview that shows next to the code editor, but it's true that there are some limits to what you can test with it.