# 应为 \`decorateCooked\` 提供 \`id\` 选项以避免内存泄漏

**URL:** <https://meta.discourse.org/t/decoratecooked-should-be-supplied-with-an-id-option-to-avoid-memory-leaks/120301>\
**Category:** Product Support\
**Created:** [2019 年6 月 13 日 20:40 UTC](https://meta.discourse.org/t/decoratecooked-should-be-supplied-with-an-id-option-to-avoid-memory-leaks/120301 "2019-06-13T20:40:12Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

作者： ![simon](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/simon/32/339122_2.png) [@simon](https://meta.discourse.org/u/simon)\
发布日期： [2019 年6 月 13 日 21:14 UTC](https://meta.discourse.org/t/decoratecooked-should-be-supplied-with-an-id-option-to-avoid-memory-leaks/120301/2 "2019-06-13T21:14:53Z")

</div>

In recent versions of Discourse there is a comment about this in the Plugin API code:

````javascript
  /**
   * ```
   * api.decorateCooked(
   * $elem => $elem.css({ backgroundColor: 'yellow' }),
   * { id: 'yellow-decorator' }
   * );
   * ```
   *
   * NOTE: To avoid memory leaks, it is highly recommended to pass a unique `id` parameter.
   * You will receive a warning if you do not.
   **/

````

It looks like all you need to do is pass an `{ id: 'your-id' }` option to the method call.

---

_[View the full topic](https://meta.discourse.org/t/decoratecooked-should-be-supplied-with-an-id-option-to-avoid-memory-leaks/120301)._
