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

AI-generated summary

A user verilog15 reported a DevTools warning: decorateCooked should be supplied with an id option to avoid memory leaks. simon explained that recent Discourse versions require passing a unique id (e.g., { id: 'your-id' }) to decorateCooked to prevent memory leaks, as documented in the Plugin API. verilog15 asked where to make the change, noting they couldn’t find decorateCooked in their theme code. simon clarified the warning likely originates from Discourse core code and can be safely ignored for now. j.jaffeux confirmed it’s only a warning, not a critical issue, and plans to submit PRs to update plugins lacking the id option in the coming weeks. The consensus is that the site will function normally, but developers should eventually add the id to comply with best practices and avoid future deprecation.

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?

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.

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.

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.