we've been using Smarty for quite a while now, and recently we succesfully upgraded to Smarty 3. Our next improvement is targeting our pagespeed, and we want to move all <scripts> to the bottom of our page. The problem is that we are working with includes, and every included file requires it's own scripts.

Where both the header.tpl and header_sub.tpl include some <script>s. Our header_sub.tpl also includes another file, based on the variable $includeHeaderSubSub. This file also has it's own <script> tags. We have 3 different sub headers, so these are splitted nicely from the header.tpl file.

I've tried moving to Template Inheritance, and using a {block} for the scripts that go at the bottom of the page. So, our typical page would look like:

But because it is included, and not inheriting, the Smarty compiler seems to think that this is the place where all scripts should be rendered.

So, my question is.. how can we move all scripts to the bottom of the page? Is Template Inheritance with {block} the way to go, and if so, how can we make it work? Or is there another technique I completely missed? How are you guys making sure all your script tags are at the bottom of your page?

That works great, when the header_sub_sub.tpl isn't being included. When it is being included (not through extending, but through {include}'ing), the scripts are all inserted at the position where header_sub_sub.tpl says {block name="scripts"}

Why not get rid of all the {include ..} tags, make your sub-templates part of the main layout and manage the content with blocks? I'm not completely following what is going on here, but you probably don't need to handle header/footers with sub-templates when going to template inheritance.