TVH7
TVH7

Reputation: 465

Codeigniter load header and footer once

Iam working an a codeigniter project. My menu header and footer are all loaded using a different view than the content view. Every page has its own controller who loads all the views. Including the header and footer views. But I want to actually load the header and footer just once. And keep them loaded. This to increase load times and remove the flicker effect when you load a page and it readjusts to your screen size.

Upvotes: 0

Views: 1028

Answers (2)

xelber
xelber

Reputation: 4637

If it is to increase the load time consider using AJAX for pages. i.e. Any clicks will load the page content in to the body area via an Ajax call. You might want to consider SEO if that's a concern.

Upvotes: 0

ChristoKiwi
ChristoKiwi

Reputation: 289

Hmm, this is an age old one.

I'm not sure you can remove the flickering with each page load entirely, even with super fast fiber connections. The only answer if your looking for instant content replacement is capturing the navigation clicks and switch out the body using AJAX, even then there may be inconsistent content loading times.

If your truly looking for stateless web development you might want to try something like Meteor? https://www.meteor.com

If none of this is an option though, remember to use CIs default template system so the header and footer are already in place in a single file and the content is then loaded into it rather than tacking 3 or more files together.

Goodluck!

Upvotes: 0

Related Questions