ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Alternatives to using embeds

April 14, 2010 5:36pm

Subscribe [7]
  • #1 / Apr 14, 2010 5:36pm

    Joe Wolin

    206 posts

    I’m finding myself wanting to use embeds in a lot of my templates, but am refraining for concerns over decrease in page-load performance.

    Most of the items I’m wanting to convert to embeds are side bars, and menu related items - both of which use ee_tags and parameters to control data formatting.

    What’s the best way I can reuse these blocks of code (including the ability to pass in parameter values) and not affect page load performance?

    Edit: This is for 1.6.x

  • #2 / Apr 14, 2010 5:39pm

    Lisa Wess

    20502 posts

    Snippets in 2.0 might be a great option.

  • #3 / Apr 14, 2010 5:40pm

    Joe Wolin

    206 posts

    Lisa, I’m using 1.68.

  • #4 / Apr 14, 2010 6:57pm

    Gareth Davies

    491 posts

    I’ve recently started using Template Morsels from Solspace with some good results - worth a look

    http://www.solspace.com/software/detail/template_morsels/

  • #5 / Apr 14, 2010 7:09pm

    Mark Jackson

    60 posts

    Hello Joe

    When you say many embeds, how many?
    Where and how does the performance hit arise?

    Regards

    Mark

  • #6 / Apr 14, 2010 8:54pm

    Joe Wolin

    206 posts

    @Gareth, thanks for the link.

    @Mark,

    I’d like to have around 4-6 embeds per template.  So I’d think this would be a huge hit on performance as it would require running through the template parser 4-6 additional times.

    I’m particularly interested in a way to go about using an ‘embed like’ include on my site - maybe I’ll switch on php and try to include these snippets early on.

    Thanks for the help, just trying to understand what the ‘pros’ are doing 😉

  • #7 / Apr 14, 2010 9:11pm

    Joe Michaud

    154 posts

    In EE 1.6.8 I know lots of folks are having success with Fresh Variables, which is a near-equivalent to Snippets in EE2.

    I personally purchased a copy of the before-mentioned Template Morsels and love it.  It breaks some of the limitations of the native EE caching system.

    Now that I am converting my sites up to EE2 I find myself hoping that snippets will soon gain some of the caching options found in Template Morsels

  • #8 / Apr 14, 2010 9:12pm

    Joe Wolin

    206 posts

    Great… thanks a lot all for the help I’ll look into these solutions further.

  • #9 / Apr 14, 2010 9:19pm

    Lisa Wess

    20502 posts

    An embed itself is not that much of a drain, 4-6 is not going to hurt you that much.

    Where it becomes a problem is based on the contents of that embed.  If you have an embed with 100 weblog entries tags, you’re going to see a major impact.

    Turn on the template debugger and watch the output; that will tell you where you need to optimize.

  • #10 / Apr 14, 2010 9:22pm

    Joe Wolin

    206 posts

    Lisa, wow template debugging shows a lot of info…  What sort of red flags should I be looking for?

  • #11 / Apr 14, 2010 9:40pm

    Joe Michaud

    154 posts

    Yea, template debugging is a LOT of information that may take some real concentration to sort through.  Personally, I put the following little snippet into every site that I do:

    {if logged_in && member_group=="1"}
    <strong>{total_queries}</strong> queries •
    <strong>{elapsed_time}</strong> seconds{/if}

    I generally put it in the footer where it won’t interfere with the layout of the site and it will only appear if a super-admin is logged in and looking at the site.  It tells you the total number of queries performed and the time taken to generate the page.

    Do a little experimenting and you will quickly gain a feel for how to optimize your page loads.

  • #12 / Apr 14, 2010 9:43pm

    Joe Wolin

    206 posts

    @joe

    I’ve actually got that in a little javascript header myself.  Most of my pages are in the range of 30-60 queries and less than a second.

  • #13 / Apr 14, 2010 9:58pm

    Joe Michaud

    154 posts

    Um, those are actually EE tags but I get what you mean.  :-D

    30-60 queries seems pretty solid to me.  If you start to employ Fresh Variables or Template Morsels (or EE2 with snippets) you will find it pretty easy to keep your query count in the 35-40 range.

  • #14 / Apr 14, 2010 10:01pm

    Joe Wolin

    206 posts

    Ok great.  Yes, I should clarify I created a javascript dropdown toolbar on my site that is showing the query data using those ee tags you mentioned.

    Some of my non-ee php programming friends gawked at this number of queries and they said they try to keep their total queries to less than 15 max.

  • #15 / Apr 14, 2010 10:02pm

    Lisa Wess

    20502 posts

    Joe, you want to look for big jumps in time between steps.  For instance.  If everything is taking .002 seconds or around there, then you have one that takes 1.5 seconds - well, you’ve got a clear issue.

    I realize that you’re still on 1.x, but just wanted to mention that the template debugger has morphed into a much more comprehensive profiler in 2.0.

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases