<!---# Loading Assets On Demand-->
# ÇÊ¿äÇÒ¶§¸¸ AssetsÀ» ºÒ·¯¿À±â


<!--If you're writing a small app you can safely ignore this section, as it's always better to pack all client assets into one file and send everything through together in one go if possible.-->

¸¸µé°í ÀÖ´Â ¾ÛÀÌ ÀÛ´Ù¸é, ÀÌ ºÎºÐÀº °Ç³Ê¶Ù¾îµµ µË´Ï´Ù. ¿Ö³ÄÇÏ¸é °¡´ÉÇÏ¸é, Å¬¶óÀÌ¾ðÆ®ÀÇ ¿¡¼Â ÇÑ ÆÄÀÏ¿¡´Ù°¡ ¸ð¾Æ³õ°í, ÇÑ ¹ø¿¡ ¸ðµÎ º¸³»´Â ÆíÀÌ ³´±â ¶§¹®ÀÔ´Ï´Ù.

<!--But what if you're writing a large app, or an app with multiple distinct sections like iCloud.com?-->
±×·¯³ª ¸¸µé°í ÀÖ´Â ¾ÛÀÌ Å©°Å³ª, ¼­·Î ±¸º°µÇ´Â ¿©·¯ °³ÀÇ ¼½¼ÇÀ» °¡Áö´Â °æ¿ì¿¡´Â ¾î¶³±î¿ä? ¿¹¸¦ µé¸é iCloud.comÀÇ °æ¿ìÃ³·³¿ä.

<!--SocketStream allows you to load code (and other assets in the future) into your app asynchronously on demand.-->
¼ÒÄÏ½ºÆ®¸²¿¡¼­´Â ¿äÃ»ÀÌ ÀÖÀ» ¶§¸¶´Ù ºñµ¿±âÀûÀÎ ¹æ½ÄÀ¸·Î ÄÚµå¸¦ ¾Û¿¡´Ù°¡ ·ÎµåÇÒ ¼ö ÀÖ½À´Ï´Ù. ³ªÁß¿¡´Â ´Ù¸¥ ¿¡¼Âµµ ÀÌ·¸°Ô ÇÒ ¼ö ÀÖÀ» °ÍÀÔ´Ï´Ù.


<!---### Loading Code-->
### ÄÚµå¸¦ ·ÎµåÇÏ±â

<!--Sadly it's not possible to directly `require()` modules which haven't been loaded as the blocking nature of the `require` function means the browser would freeze until the module has been retrieved from the server - not good.-->

¾ÈÅ¸±õ°Ôµµ, ·ÎµåµÇ¾î ÀÖÁö ¾ÊÀº ¸ðµâÀ» Á÷Á¢ `require()`ÇÒ ¼ö´Â ¾ø½À´Ï´Ù. `require` ÇÔ¼ö´Â ¼­¹ö·ÎºÎÅÍ ¸ðµâÀ» °¡Á®¿Ã ¶§±îÁö ºê¶ó¿ìÀú´Â ¸ØÃä´Ï´Ù.

<!--However SocketStream allows you to load additional code modules from the server asynchronously using the built-in `ss.load.code()` command. Once all the code you've requested has been loaded, we execute a callback, allowing you to `require()` the new modules as normal without any fancy syntax.-->

ÇÏÁö¸¸ ¼ÒÄÏ½ºÆ®¸²¿¡¼­´Â `ss.load.code()` ¸í·É¾î¸¦ »ç¿ëÇØ¼­, ºñµ¿±âÀûÀ¸·Î ¼­¹ö¿¡¼­ Ãß°¡ÀûÀÎ ÄÚµå ¸ðµâÀ» ·ÎµåÇÒ ¼ö ÀÖ½À´Ï´Ù. ÀÏ´Ü ¿©·¯ºÐÀÌ ¿äÃ»ÇÏ½Å ÄÚµå°¡ ´Ù ·ÎµåµÇ¸é, ¼ÒÄÏ½ºÆ®¸²¿¡¼­´Â ÄÝ¹éÀ» ¼öÇàÇÕ´Ï´Ù. ±×·¡¼­ Æ¯º°ÇÑ ±¸¹®À» ¾²Áö ¾Ê¾Æµµ, `require()`¸¦ »ç¿ëÇØ¼­ »õ·Î¿î ¸ðµâÀ» ·ÎµåÇÒ ¼ö ÀÖ½À´Ï´Ù.

<!--To try this out, create a new directory of application modules in `/client/code`. For the sake of this example, let's call our new directory `/client/code/mail`. We'll also assume this directory has a module in it called `search.js`.-->
Á÷Á¢ ÇØº¸¼¼¿ä. ¾îÇÃ¸®ÄÉÀÌ¼Ç ¸ðµâ¿¡ »ç¿ëÇÒ »õ·Î¿î Æú´õ¸¦ `/client/code` ÇÏÀ§¿¡ ¸¸µå¼¼¿ä. ±×¸®°í »õ·Î¿î Æú´õ¿¡ `/client/code/mail`ÀÌ¶ó°í ÀÌ¸§À» ºÙÀÌ¼¼¿ä. ÀÌ Æú´õ ¾È¿¡´Â `search.js`¶ó´Â ¸ðµâÀÌ ÀÖ´Ù°í °¡Á¤ÇÏ°Ú½À´Ï´Ù.
```javascript
//Å¬¶óÀÌ¾ðÆ®ÂÊÀÇ ¸ðµâ
ss.load.code('/mail', function(){

  // /client/code/mail ¾È¿¡ µé¾îÀÖ´Â ¸ðµâÀÌ ¸ðµÎ ·ÎµåµÇ¾ú½À´Ï´Ù.
  // ·çÆ®ÀÇ ³×ÀÓ½ºÆäÀÌ½ºÀÎ (/)(??)´Â º¸ÅëÀÇ ¹æ¹ýÀ¸·Î ¿äÃ»ÇÒ ¼ö ÀÖ½À´Ï´Ù.

  var search = require('/search');

});
```
<!--  // all modules in /client/code/mail have now been loaded into-->
<!--  // the root namespace (/) and can be required in the normal way-->
<!--// in any client-side module-->



<!--Note: Regardless of the directory you load, the modules inside will always be loaded into the root (/) namespace by default. If you want to mount the new modules in a different namespace, just create one or more sub-directories in the folder you're loading.-->

ÁÖÀÇÇÏ¼¼¿ä: ¿©·¯ºÐÀÌ ·ÎµåÇÏ´Â Æú´õ¿Í »ó°ü¾øÀÌ, Æú´õ ¾È¿¡ ÀÖ´Â ¸ðµâÀº º°µµÀÇ ¼³Á¤ÀÌ ¾øÀ¸¸é Ç×»ó ·çÆ® (/) ¾È¿¡ ·ÎµåµÉ °ÍÀÔ´Ï´Ù. »õ·Î¿î ¸ðµâÀ» ´Ù¸¥ ³×ÀÓ½ºÆäÀÌ½º ¾È¿¡ ¸¶¿îÆ®ÇÏ½Ã·Á¸é ·ÎµåÇÏ½Ã·Á´Â Æú´õ¸¦ ÇÏ³ª ¸¸µé°Å³ª, ·ÎµåÇÏ´Â Æú´õ ¾È¿¡ ÇÏÀ§ Æú´õ¸¦ ÇÏ³ª ¸¸µå¼¼¿ä.


<!---### Automatic Caching-->
### ÀÚµ¿ Ä³½Ì

<!--Modules are only ever retrieved from the server once. Subsequent requests for the same directory will be returned instantly without contacting the server.-->
¸ðµâÀº ¼­¹ö·ÎºÎÅÍ ÇÑ ¹ø¸¸ °¡Á®¿É´Ï´Ù. µ¿ÀÏÇÑ Æú´õ¿¡ ´ëÇØ ±× ÀÌÈÄ¿¡ ÀÌ·ç¾îÁö´Â ¿äÃ»Àº ¼­¹ö¿Í Á¢¼ÓÇÏÁö ¾Ê°í ¹Ù·Î ¹ÝÈ¯µË´Ï´Ù.
