(WordPress 5.8.3) Function.php or a plugin for better performance? [duplicate]

There’s zero meaningful difference in performance between plugins and functions.php. All plugins are is PHP files that WordPress will run as it loads, and functions.php is just a file in the theme that WordPress run as as it loads.

Performance is not a consideration when choosing between a plugin and functions. The right choice depends entirely on what the code does, and even then is largely a matter of opinion, so you’re not going to get a definitive answer.

The closest you might get is the rules for submitting themes to wordpress.org. Those rules state that themes should not include:

  • Custom post types
  • Custom blocks
  • Custom roles
  • Custom user contact methods
  • Custom mime types
  • Shortcodes
  • Functionality that is not related to design and presentation

These rules are not at all related to performance. They enforce a certain point of view of what best practices are, but they primarily exist to ensure users can easily switch themes without loss of functionality or content.

Please note that these are merely the rules for a single theme repository, albeit the most popular one. They may or may not be appropriate for other repositories or projects. That again depends entirely on the nature of the code and the project, and would be a matter of opinion.