The functions.php file should be known to everyone developing a wordpress theme, as it’s a neat way to group all your theme’s utilities, as well as load special files, scripts and override the default, out-of-the-box wordpress functions and loaded javascript files.
However, there are a few things one need to remember when writing code in that file, and it’s not always easy to understand why. Specifically, registering and enqueueing scripts can be a bit tricky if you don’t understand how the functions.php file is loaded.
One of the biggest problem is understanding the scope and load/execution time time of what is in that file. I’ve scratched my head a few times on it, and hopefully, I now understand it better and will manage to write it down correctly! (more…)