`decorateCooked` should be supplied with an `id` option to avoid memory leaks

For some reason I get the following warning in the DevTools:

image

decorateCooked should be supplied with an id option to avoid memory leaks.

What could be the issue? How should I solve it?

1 Like

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

  /**
   * ```
   * 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.

2 Likes

thank you. I’m not sure where to change it though. Tried to grep “decorateCooked” in the theme I use but could not find it. Maybe it’s in the settings? Not sure where it should be.

Sorry, I had assumed this was an issue with a theme you were developing. The deprecation notice seems to be coming from the Discourse code. I think you can ignore it for now.

1 Like

Yes nothing very bad to worry about. I will make PR to various plugins not providing this ID in the next weeks, it’s just a warning and shouldn’t prevent your site from working correctly.

2 Likes