Pete Posted March 14, 2012 Share Posted March 14, 2012 Not sure context is the right word for this, but I'll use it anyway! It just occurred to me that the more modules you have the more modules the system has to run to see if they apply to the current action. Some run solely on the front-end, some only in admin, and many only when editing pages. Would it not make sense to have some basic information required for ALL modules and stored in the database so that the system doesn't have to include and run every module to see if it's applicable? I know there's scope to go crazy with it, but I think that a few basic settings would save a little overhead. I also know that a few kilobytes never hurt anyone so what's all the fuss about That's assuming that this is how it works and I'm not missing something obvious. Link to comment Share on other sites More sharing options...
ryan Posted March 14, 2012 Share Posted March 14, 2012 The only modules that PW loads on every request are: 1) those called upon by that request, aka on-demand; or 2) those designated as 'autoload'. Most modules are of type 1 (on-demand) so they aren't included or loaded (or taking up memory) unless asked for. When it comes to autoload modules, it is a best practice for autoload modules not to add their hooks until they've determined that they are applicable to the given request. For instance, an autoload module that only needs to do something in the admin would add a hook from its ready() function after determining that the $page was part of the admin. Down the road, there is room for further optimization here. We could have an autoload module that only loads when template is 'admin' or page is X or has parent Y, or any number of things. But this is added complexity for both the user and the module developer. So it's something I'm not sure we need to consider too much until memory issues are a concern. Currently memory is not an issue, even with a lot of autoload modules. But longer term we will benefit from an 'autoload if' type designation for modules, and good to start planning for. Link to comment Share on other sites More sharing options...
Pete Posted March 14, 2012 Author Share Posted March 14, 2012 Yep - I didn't think it would be an issue really memory-wise, but as I just installed an 8kb (huge ) module and looked down the list at a few others that run on page load an/or save, I just thought they might begin to stack up eventually. I suppose the only issue with those is if they're designed to use selectors and have a lot of data to look through and are being loaded unnecessarily, but then that's probably more to do with the module's design, as if it's built well enough then one of the first checks on one of the first lines of code should be whether you're in the admin or not (if that's a check you need to run in a specific module). I guess I worry with my own modules more than others 1 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now