2

I need to know which method is faster.

<?php echo $this->getLayout()->createBlock('cms/block')->setBlockId('header_top')->toHtml(); ?>

Or the layout rendering.

<block type="cms/block" name="header_top" as="header_top" before="header">
      <action method="setBlockId"><block_id>header_top</block_id></action>
</block>
  • second once is faster – Amit Bera May 19 '17 at 6:30
  • Why it is more faster? – Salma Saiyad May 19 '17 at 6:37
4

AFAIK second one is faster.

Your question is Why? ,

Then here is my answer,

IN second method.

because when page is load at that time all layouts were merged into one and all necessary blocks were called.

In First Method

When necessary Phtml or PHP file were called at that time this block is called and also this block cache lifetime depend on parent block where its called.

So at my point of view second Method is faster.

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.