# Class: ImageCache Image cache layer. Allows you to cache HTMLImageElement so you can create them once Lazy loading has been handled. ### Properties #### cache • `ProtectedReadonly` **cache**: [`Map`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Map)<`string`, [`HTMLImageElement`](https://developer.mozilla.org/docs/Web/API/HTMLImageElement) \| () => [`HTMLImageElement`](https://developer.mozilla.org/docs/Web/API/HTMLImageElement)> Cache map ### Methods #### register ▸ **register**(`key`, `src`, `lazy?`): `this` Register an image in the cache. ##### Parameters {{< table-wrapper >}} | Name | Type | Description | |:--------|:----------|:--------------------------------------------| | `key` | `string` | Name of your image | | `src` | `string` | Source url/path of your image | | `lazy?` | `boolean` | Should lazy load the image (default: false) | {{< /table-wrapper >}} {{< fake-header "5" "Returns" >}} `this` ------------------------------------------------------------------------ #### get ▸ **get**(`key`): `undefined` \| [`HTMLImageElement`](https://developer.mozilla.org/docs/Web/API/HTMLImageElement) Get HTMLImageElement by key ##### Parameters {{< table-wrapper >}} | Name | Type | Description | |:------|:---------|:-------------------| | `key` | `string` | Name of your image | {{< /table-wrapper >}} {{< fake-header "5" "Returns" >}} `undefined` | [`HTMLImageElement`](https://developer.mozilla.org/docs/Web/API/HTMLImageElement) ------------------------------------------------------------------------ #### has ▸ **has**(`key`): `boolean` Check if an image exists by key ##### Parameters {{< table-wrapper >}} | Name | Type | Description | |:------|:---------|:-------------------| | `key` | `string` | Name of your image | {{< /table-wrapper >}} {{< fake-header "5" "Returns" >}} `boolean` ------------------------------------------------------------------------ #### loaded ▸ **loaded**(`key`): `boolean` Check if an image has been loaded ##### Parameters {{< table-wrapper >}} | Name | Type | Description | |:------|:---------|:-------------------| | `key` | `string` | Name of your image | {{< /table-wrapper >}} {{< fake-header "5" "Returns" >}} `boolean`