I was wondering if anyone knew which of the following is most efficient (or an alternative if applicable). The idea is to create a header containing information for a specific node. This assumes all other variables, such as caching being equal. This would be for a Drupal 7 install.

i) Create a block, restricting it to the specific node


ii) Create a custom tpl with the information hard-coded (I know it's a Drupal no-no)

Using a block is simpler to deal with and update for obvious reasons, but I was curious if there was any significant difference in page rendering time, or resources used, etc.


A custom template always results in better performance. Views and blocks are stored in the database which need to be queried and rendered first. Whereas templates require less memory and cpu because the php can be executed directly. When using a template you also have the advantage of SCMs like git or subversion.

The performance difference between templates and blocks won't be noticeable as soon as you enable caching on your site .

So what should you use? It is completely depending on the case. If your header will be shown on multiple pages, i'd go with a template. If you'll show it only on seperate pages (whitelisted urls), I'd go with the block.

  • In terms of use case there is also where the content comes from - is it user editable and if so where will the user edit it; and if it is only on certain pages, how are those pages determined - a set list of pages or something more dynamic; and other considerations depending on the requirements. Also, git/subversion are also relevant to blocks if you make your block in a module instead of via the UI. – rooby May 17 '14 at 8:02
  • @rooby - this assumes static, admin defined and rarely changing data. The block would be created via UI – Geoff May 18 '14 at 5:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.