CodeIgniter Forums
When should I autoload a library? - 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 should I autoload a library? (/showthread.php?tid=41546)



When should I autoload a library? - El Forum - 05-10-2011

[eluser]nyxynyx[/eluser]
Hi, I'm wondering when I should autoload libraries and when should I load it in the controller when required? If I use a particular library on 50% of the pages viewed daily, should I autoload it? Is there a significant performance impact of autoloading libraries? Sorry I'm new to this Smile


When should I autoload a library? - El Forum - 05-10-2011

[eluser]InsiteFX[/eluser]
The impact would be memory usage.

I usally autoload the databse and session libraries.

If you are using the library a lot then yes I would autoload it, but you can always load them on demand!

InsiteFX


When should I autoload a library? - El Forum - 05-13-2011

[eluser]LinkFox[/eluser]
If you're using it all over your application then autoload it, I.E Session, however things like form_validation would only really be used on pages with forms so should be loaded when you need it.

I'd say only autoload if 60-70% of your controllers require the library/helper etc, but its a personal preference and its best to learn by tweaking really.

Hope this helps

Regards

David