In the Forums: Snippets and Embeds
There is a lot to be written about Snippets (new in EE 2) versus Embed Templates. But for now, I want to point you to a thread in the archived forums from earlier this year where Lisa Wess (EllisLab) explains some more about snippets and how they differ from Embeds.
[W]e recommend Snippets over Embeds unless you need to do something such as pass variables. Snippets are treated exactly as if that code was directly in the template, whereas embeds are treated as entirely separate entities. Embeds are absolutely “heavier” than snippets.
For more about Snippets, read the documentation for the why and what.
Judd — 09:11 on 07.20.2010
Until they make snippets editable as files on the server, I’ll keep using embeds. It’s annoying to be locked into a textarea during development IMO.
Maleika E. Attawel — 06:18 on 07.21.2010
I’ve been using snippets for my upcoming website and must say that I do notice a performance difference between embeds and snippets, which is why I’ve resorted to using the latter almost exclusively.
It’s a fantastic idea but, like Judd noted, it’d be a lot more convenient for the day-to-day EE workflow if these were editable outside the EE interface.
Christopher B. — 21:51 on 09.22.2010
That article above says according to Lisa to use Snippets most everywhere when possible. Where is the more recent article staffers say to use them sparingly: http://expressionengine.com/forums/viewthread/167439/
I’ve read several forums on the matter and their seems to be no consensus. Especially amongst the EE forum moderators. Such as Susan saying she never uses Snippets and Lisa saying to use whenever possible.
I seeing this issue a lot on the forums where no one seems to agree on the basics. I guess it comes down to taking all these forum suggestions with a grain of salt anda checking performance results of each on our own.
Christopher B. — 21:54 on 09.22.2010
Rather than looking at the advice above this page seems more helpful on when to use each:
http://expressionengine.com/user_guide/templates/embedding_templates.html
How to choose between an Embedded Template and a Snippet
Since Snippets can also contain tags, variables, and PHP, the question often arises: which do I choose? If your content meets one of the following criteria, use an Embedded template.
You need Embed Variables.
You need separate PHP parsing preferences from the template this code is being added to.
You need separate caching preferences from the template this code is being added to.
You need separate template Access control from the template this code is being added to.
You need to also be able to access this template on its own directly via the URL.
You need to edit this content using the flat-file template system.
You need to more discretely control which users are allowed to modify this content.
In all other cases, Snippets are typically the better solution, as the above features do come with a minor associated cost in terms of resource usage. Choose the right tool for the right task!