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.

Embed Variables vs Global Variables?

December 29, 2011 9:07pm

Subscribe [8]
  • #16 / Feb 01, 2012 5:30pm

    Is there a performance difference between snippets and GVs? Since snippets are can contain more functionality wouldn’t the additional parsing make them slightly slower?

  • #17 / Feb 02, 2012 9:38am

    John St-Amand

    865 posts

    If each was holding static content, I believe the difference would likely be almost imperceptible.  But once you start using EE tags in a snippet, which a global variable can’t do, the difference between them widens as the complexity of the EE tags in the snippet grows.  It’s a tough comparison.

    I generally use global variables for things that absolutely need no parsing of any kind.  I reserve snippets for anything that needs EE power without the template engine overhead.

  • #18 / Feb 02, 2012 9:45am

    John St-Amand

    865 posts

    Incidentally, Boyink’s preference for snippets over global variables is an important one. At least with snippets, you can draw its content from channel entries, relieving yourself of the burden of having to give the client access to the templates area of the CP - the only way you would be able to give them access to global variables content natively in EE.  I tend to get around this for clients that really need it one of two ways:

    1) Use snippets for everything the client might need to edit and draw the content of the snippets from channel entries, including a “site settings” channel just for holding a whole bunch of global variable-like items

    2) Use Low’s outstanding Low Variables add-on to turn global variables into a client-accessible module WITHOUT giving them access to the templates area.  The only limitation to this approach that I’ve found is that there are a few custom field types that i like to use that I would ordinarily include in my “site settings” channel that are not yet integrated with Low Variables - Tagger from DevDemon, being an example.  But that’s a pretty minor issue.

    Hope you find that useful.

    John

  • #19 / Feb 02, 2012 10:14am

    That’s kinda what I thought about the speed, thanks. I’ve been using the same approach of global variables for static content - Google Analytics, IE6 chrome frame, etc. The point on client editing is a good one, hopefully a future update will allow direct access to global variables with template access. Thanks John!

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

ExpressionEngine News!

#eecms, #events, #releases