Does Craft parse the contents of a false/negative/empty conditional statement? So would you take a performance hit if you had a big chunk of code inside a conditonal that was false?

{% set foo = "foo" %}
{% if foo == foo %}Small code {% else %} MASSIVE CODE{% endif %}

1 Answer 1


Yes, Twig will parse it all down to PHP before running it. It stores the rendered PHP in a /storage/runtime/compiled_templates/ file.

No, Craft will not run anything inside the conditional if it's false. At that point, it's simply processing exactly as normal PHP would.

So no, you shouldn't be notably penalized for anything inside a falsey if statement.

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.