Answers.Body: <p>This is definitely not a great answer, but I'm not sure anyone's going to be able to really answer this. You'd have to set up some sort of unit tests or something. And it will probably depend a lot on your server environment. But think of all the class files that need to get loaded just to handle a simple request. Personally, I think that the performance hit on an import statement is going to be pretty tiny regardless. I would opt for importing them in whatever way makes the most sense from a development/organizational perspective.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-12-19T06:47:01.183Z
Answers.Text: I agree, I'd imagine the performance hit to be negligible. Don't forget, Twig compiles down to PHP, and that PHP is then cached. So basically, you'll end up with a slightly larger-than-necessary PHP file, but it shouldn't really affect your performance overall. Moral of the story... **your personal preference and sense of organization trumps any insignificant performance issues.**
Answers.UserDisplayName: Lindsey D
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-12-19T00:22:15.743Z
Answers.LastActivityDate: 2014-12-19T00:22:15.743Z
Answers.UserDisplayName: Douglas McDonald
Body: <p>In my base template extended by all other templates, I import my macros, so I have global use of them throughout my templates.</p>
  
  <p><strong>Question 1:</strong>
  Am I taking a performance hit for including these whether or not I'm using them in a given template?</p>
  
  <p><strong>Question 2:</strong>
  Is there any advantage to splitting up macros into different imports, other than just organization?</p>
  
  <p>In other words, is there any reason not to do:</p>
  
  <pre><code>{% import "_includes/macros" as macros %}
  </code></pre>
  
  <p>And have <code>_includes/macros</code> have <em>all</em> my macros?</p>
  
Tags: <templating><macro>
Title: What is the advantages/disadvantages of separating macro imports?
ThreadText: # What is the advantages/disadvantages of separating macro imports?
  
  (Asked by: username_0 on 2014-12-18)
  
  In my base template extended by all other templates, I import my macros, so I have global use of them throughout my templates.
  
  **Question 1:**
  Am I taking a performance hit for including these whether or not I'm using them in a given template?
  
  **Question 2:**
  Is there any advantage to splitting up macros into different imports, other than just organization?
  
  In other words, is there any reason not to do:
  
  ```
  {% import "_includes/macros" as macros %}
  
  ```
  
  And have `_includes/macros` have *all* my macros?
  
  **Tags:** templating, macro
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2014-12-19. Score: 2 | Accepted answer
  
  This is definitely not a great answer, but I'm not sure anyone's going to be able to really answer this. You'd have to set up some sort of unit tests or something. And it will probably depend a lot on your server environment. But think of all the class files that need to get loaded just to handle a simple request. Personally, I think that the performance hit on an import statement is going to be pretty tiny regardless. I would opt for importing them in whatever way makes the most sense from a development/organizational perspective.
  
  > **Comments:**
  > **username_2**: I agree, I'd imagine the performance hit to be negligible. Don't forget, Twig compiles down to PHP, and that PHP is then cached. So basically, you'll end up with a slightly larger-than-necessary PHP file, but it shouldn't really affect your performance overall. Moral of the story... **your personal preference and sense of organization trumps any insignificant performance issues.**  
  
  ---
  
  