[eluser]brian88[/eluser]
Ive been loading view by using a template. But I wanna know which is the fastest way, not for me, but for users to download the page. So here I have 2 controllers and I wanna know whats the better way. Or if theres a better way other than these 2 options, give me some feedback( I dont want to use a big templating library, not a fan )
controller 1
Code:
// set SEO
$data['title'] = 'title';
$data['h1'] = 'h1 stuff';
$data['description'] = 'my description';
$data['info'] = 'more data...';
// get data
$data['nav'] = $this->main_mod->getNav();
$data['posts'] = $this->main_mod->getPosts();
// load views
$data['content'] = 'main/home';
$this->load->view('templates/main', $data);
In this one I pass data to views that don't even need it, which would slow down the page, correct?
or
controller 2
Code:
// set SEO
$seoData['title'] = 'title';
$seoData['h1'] = 'h1 stuff';
$seoData['description'] = 'my description';
$infoData['info'] = 'more data...';
// get data
$navData['nav'] = $this->main_mod->getNav();
$data['posts'] = $this->main_mod->getPosts();
// load views
$this->load->view('header_view.php', $seoData);
$this->load->view('info_view.php', $infoData);
$this->load->view('nav_view.php', $navData);
$this->load->view('home_view.php', $data);
$this->load->view('footer_view.php');
This one takes longer to do, but if the page loads faster for users then I dont mind doing it.