CodeIgniter Forums
When to $this->load - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: When to $this->load (/showthread.php?tid=54785)



When to $this->load - El Forum - 09-25-2012

[eluser]davlyn[/eluser]
Performance wise, and general good practice wise when it is recommended to load a certain helper or lib?

Or in other words when should load in:

1. Auto load?
2. Controller level so that every method can access it?
3. Method/Function?

Same could be asked for models also.




When to $this->load - El Forum - 09-25-2012

[eluser]Otemu[/eluser]
1. If you commonly use the helper/lib or model throughout your site then autoload it
2. If you commonly use the helper/lib or model in every function of that controller then load it at controller level
3. If it not commonly used in other method/functions then load it at this level

In terms of benchmarking I am not sure how much diff it makes, could be talking milliseconds.


When to $this->load - El Forum - 09-25-2012

[eluser]davlyn[/eluser]
Thanks, that mases sense.