Welcome Guest, Not a member yet? Register   Sign In
Loading Views: Efficiency question
#1

[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?
#2

[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
#3

[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.
#4

[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




Theme © iAndrew 2016 - Forum software by © MyBB