1

I'm finding a few add-ons/modules that are loading on every page/template even if they are not being called in that template.

For example, the Solspace Favorites module seems to constantly be coming up on every page of the site even though it is only being called with tags and used in only 2 pages/templates.

The issue is that it's also causing increases in memory usage (not crazy amounts but still). Is this normal and is there any way to avoid this?

Favorites being called on a page/template that doesn't use Favorites at all

Thanks! Dan

1 Answer 1

2

At least for Favorites, the add-on uses a hook, channel_entries_tagdata, which is a hook present in the EE Channel:Entries module. Any add-on that uses this hook will be called when the EE Channel:Entries module is used. This includes when {exp:channel:entries} is used, but can include other tags where the Channel:Entries library is being used, eg. {exp:favorites:entries}.

Hooks usually extend a feature in EE. In the case of channel_entries_tagdata, the hook can be used to modify the Channel:Entries tag data, for example to add additional variables that can be parsed by {exp:channel:entries}. If you had Matrix or Playa installed, for example, you might also see calls to these modules since they also use this hook, likely to add the ability to parse Matrix/Playa variables (don't take my word for it).

Simply calling a hook does not add a lot of overhead: a function called by the hook might exit immediately, with no queries or heavy processing happening. Favorites does this: it checks if there's anything related to Favorites with the tag, and if not, exits the function. A look at the Output Profiler should not show Favorites-specific queries if Favorites is not mentioned in your code.

Unfortunately there is no way modify this behaviour, since this is how hooks work in EE: EE triggers a hook, looks for all add-ons that use the hook, and runs each add-on function that uses the hook. It's the add-on developer's responsibility to exit early (or use cached data instead of queries/loading librairies) if nothing needs to be done when the function is called. EE's Template Debugger, however, will still log the hook call, even if nothing happens when the hook function is called.

You could disable the extension for an add-on, but then you would lose its functionality when it's needed.

1
  • Thank you for clarifying this for me! As I think the Twitter conversation has gone as well, it would be great if EE came up with an option similar to the disable parameter so that extensions that won't be used in a particular tag aren't called at all...leads to better efficiency.
    – DanH
    Commented Mar 3, 2015 at 16:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.