Hello all!
I have (what I consider to be) a relatively large project that I have been working on for over a year. In an effort to reduce coding and increase efficiency I created a functions.php file that I've been putting the code that is reuse a lot throughout the project into functions. The file contains fundamental aspects to the project (such as connecting to the database, printing the navigation menu, etc.) so it's included on pretty much every page in the site.
Due to the size of the project and the "scorched Earth" approach of the functions file, it has grown relatively large. With plenty more functionality planned for my project, the functions file is sitting at just over 1,300 lines and will definitely grow larger. My question is simple: what's the best practices for a functions file like this? At what point does its size start to compromise speed of the project?
According to Explorer, the file is 50KB. Should I be splitting this file into smaller chunks to reduce page loading times? I haven't noticed any noticeable delay and neither have my five testers. In terms of maintainability, it's not difficult for me at all since I've divided the file into sections via comments, and quite frankly it's much faster for me to hit ctrl-F than to find a specific file referring to a specific function. This is a personal project and I'm the only one working on it, so theoretically no one else should ever have to read my code.
But, with that said, should that time ever come, or if I want to show my code to a potential employer, etc. I'd like to know what I've done is considered the best approach. At what point should I be breaking up this file into smaller chunks, if at all? I suppose I could separate the database connection into another file.
Thank you for reading and any opinions would be greatly appreciated. 🙂