View Full Version : Does using replacement variables has imapct on performance?
Chris8
06-10-2012, 08:44 PM
Does using replacement variables has impact on performance?
Let say I will use in templates in hundreds of places one replacement variable, will it have any impact on performance when compared to using static text?
I'm wondering if I should use replacement variable or to do manual edits for all child styles that will reflect the difference between main and child styles. Both ways seems to be ok, I'm just not sure what would be better for performance. Altering loads of child style templates or using one single replacement variable that will be different for all styles???
Yup, I know I repeat myself, it's just for better understanding. :D
Lynne
06-10-2012, 11:23 PM
It can, yes. I doubt it would be a huge effect, but if you have many of them, and your site is really, really busy, and you don't have a great server, then you may see an affect. Could be a small affect, but still and affect.
Chris8
06-11-2012, 05:10 PM
Thank you Lynne.
So, it would be better for performance to alter child styles?
I'm asking because I'm not sure how theme system works. The templates are inherited from parent style. When I alter most of the child templates then will they behave like independent templates or will everything be inherited and only the changed code pieces will be pulled out of database? I'm not sure how it works. :confused:
Lynne
06-11-2012, 11:19 PM
If you have a Parent style and you have a footer template in it, then you have a Child style that is a child of the Parent..... if you do not edit the footer template in the Child style, then it will use the footer template from the Parent style. However, if you edit the footer in the Child style, then any edits you do to the footer in the Parent style will not get magically merged into the Child style footer template (thus, the Child style modified footer template is independent of the Parent style footer template).
As for the better performance, it's hard to say since we know nothing about your site or server or anything. If it were me, I'd go the easy route of using Replacement Variables and if the server loads are fine, then go with it until sometime in the future when the server loads are no longer fine.
Chris8
06-12-2012, 12:05 AM
Thanks! Well, that's what I was guessing too, cause that was logical, however, sometimes things are not that simple as they seem to be and it's better to ask and to make sure just in case. ^^'
I think I get it now.
And I think I will never get to know what would be better in terms of performance so, I will just proceed with one option.
My server load averages are always at 0 cause the site is still in development stage and not live. I'm not worrying about future sever needs but I always try to think 5 steps forward with everything... just in case. :)
... And I think I will never get to know what would be better in terms of performance so, I will just proceed with one option.
I'm pretty sure that if you edit a lot of templates in a child style to add static text, there would be no performance difference over using the parent style. Like Lynne said, there's no on the fly merging going on - each style is just a list of template ids. If a child style hasn't modified a template, then the id for that template will be the one from the parent style. The replacement variables are done by doing a preg_replace() on the entire document as one of the last steps before it's sent, so it's got to add some processing time, but I agree with Lynne when she says that unless you have a busy server it's most likely not going to be a problem.
(Sorry if I just repeated what you already understood - it sounded like maybe you still had a question).
Chris8
06-13-2012, 10:39 PM
Yeah, I understand. I just modified child templates where it was necessary. It's possible that I would modify them anyway so it's best choice I think. Replacement variables are very useful too though and I used them to alter some bbcodes that are dependant on styles.
Thank you both for making things more clear. :)
I always try too look up my questions before asking sometimes though I can not find answers so I ask.
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.