←back to thread

299 points solcloud | 1 comments | | HN request time: 0.213s | source
Show context
peppertree ◴[] No.41917190[source]
FYI client side is under www/assets. https://github.com/solcloud/Counter-Strike/tree/master/www/a...

There are no dependencies besides threejs. No typescript or build pipeline. Actually fun to just read the code.

replies(1): >>41917469 #
solcloud ◴[] No.41917469[source]
thank you, yes like you said all client-side dependencies are "bundled" inside repository, for reading client code start.js is good starting point (https://github.com/solcloud/Counter-Strike/blob/master/www/a...), for server side starting point is server.php (https://github.com/solcloud/Counter-Strike/blob/master/cli/s...)
replies(1): >>41921873 #
maxloh ◴[] No.41921873[source]
What is the reason behind wrapping code inside an IIFE (Immediately Invoked Function Expression)?

JavaScript modules are scoped, so nothing can be accessed outside unless explicitly exported.

FYI, you don't even need an IIFE. ES modules are block-scoped by default.

  // Instead of,
  let foo
  (function() {
    const bar = 1
    foo = bar
  })()
  // `bar` is out of scope here

  // You can just,
  let foo
  {
    const bar = 1
    foo = bar
  }
  // `bar` is out of scope here too
replies(1): >>41922959 #
1. solcloud ◴[] No.41922959[source]
I guess history reasons