User talk:Polaris999/Template Optimisation

(it explains why my templates to transclude all TAF file for CG article no longer work as they did when I wrote them; and why there is no solution to this problem)
 * KEEP THIS PAGE -- IT IS IMPORTANT DOCUMENTATION ***

Template optimisation
I've created a template to convert between various units of length. So far it can convert between 9 different units (and I plan to add more) in any combination, then I added some "aliases" to make the template more robust, that is it doesn't care if you type in "metre" or "meters" or just "m" and so on, however to do this I basicaly have to duplicate the code a bunch of times in a switch statement, since all these combinations can be combined in any way the code is getting rater large with lots of redundancy, and the more units (and aliases) that gets added it becomes more and more cumbersome to edit. Anyone know of some neat tricks to help optimise things like this? The only thing I can think of is to call various redirecting meta templates, but I understand that's a bit of a no-no... Template is length conversion by the way, use for example like so: wich outputs:. It works ok, just getting a bit stressfull to update, any help would be welcome. --Sherool (talk) 19:29, 3 November 2006 (UTC)
 * Also is there a performance issue with loading a 120+K template for something like this? --Sherool (talk) 19:36, 3 November 2006 (UTC)
 * Hi Sherool! Great template! I've made some changes, mostly spelling and allowing for unnamed parameters, but it looks great!  I'll check it out now to see if I can limit the file size.  Well done! — Mets501 (talk) 19:58, 3 November 2006 (UTC)
 * OK, here's my total changes. It's down from 120kb to 40kb now! — Mets501 (talk) 20:21, 3 November 2006 (UTC)
 * Yes, there is a performance issue; that's why there's a limit on the total size of the transcluded templates before the parser stops transcluding any new templates. Huge templates like that will hit the limit sooner. --cesarb 20:58, 3 November 2006 (UTC)
 * (In reply to Sherool) Especially read . I've left a note on Template talk:Length conversion. Please consider avoiding such monster templates. --Ligulem 23:13, 3 November 2006 (UTC)
 * I trimmed it down further (about 20Kb) and it still seems to work as well as ever. Is there any recomended maximum size on templates? As I understand it the 1Mb thing is a hard limit on the sum of all transclutions per article. --Sherool (talk) 01:27, 4 November 2006 (UTC)
 * Correct, which means that you can include this about 50 times tops per page, and that's assuming no other transclusions. I think you'll find that's rather limiting.  Templates were never intended to be a programming language, and still aren't.  A new ParserFunction would be much better for this. —Simetrical (talk • contribs) 02:40, 5 November 2006 (UTC)
 * now has only three transculsions:
 * its own doc page,
 * the template page itself (by transclusion of the doc page) and
 * here
 * Instead of this template there is an array of single-purpose conversion templates editors can use and there is the multi-purpose, all of which are slimmer in terms of pre-expand size (to my knowledge).  It can be deleted.
 * I think you were on the right track with the meta-template idea.   owes it's slimness to this.  As for its being a no-no, I believe that that was a proposal which got regected.  Here we see a very good reason for such regection.
 * Jɪmp 03:12, 15 January 2008 (UTC)