CodeIgniter Forums
Loading Views: Efficiency question - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forum-23.html)
+--- Thread: Loading Views: Efficiency question (/thread-5874.html)



Loading Views: Efficiency question - El Forum - 02-06-2008

[eluser]fdog[/eluser]
Before CodeIgniter I used to load embedded views using standard php inside the current view like:
Code:
<?php include ("header.php"); ?>

I really like the way CI handles loading multiple views from the controller and I want to change my old sites to match this technique.
Could this change slow (or speed up Smile ) the rendering of the pages?


Loading Views: Efficiency question - El Forum - 02-06-2008

[eluser]tonanbarbarian[/eluser]
Technically it will slow you down
Because to load in CI requires you to call a seperate function i.e. $this->load->view
Each function call you make takes a toll on the performance
Also to make sure that data is available in the view it must be extracted before the view file is included.

however on the plus side once you start to use CI you can take advantage of its cache which can improve performance


Loading Views: Efficiency question - El Forum - 02-06-2008

[eluser]Derek Allard[/eluser]
Yeah, and while tonanbarbarian is absolutely correct that it is technically slower, it'll still be freaky-fast, and I doubt you'd ever notice a performance hit.


Loading Views: Efficiency question - El Forum - 02-06-2008

[eluser]Lone[/eluser]
And the biggest advantage is the ability to pass 'data' to that view eg.

Code:
$data['title'] = 'Best page';
$this->load->view('header',$data);

And the $data['title'] is auto-magically accessed as $title in the view Smile