How big is too big for plugin.php
Hi All,

Just wondering some thoughts again here.

I am writing a plugin all coming through misc.php in the plugin file I have several different functions, ive barely scratches the surface of the plugin front-end at the moment and the file is starting to push 20kb. Now I know that doesn't sound a lot, however this will at least double by the time I am done if not go up to 100Kb.

Again that isn't huge, but I am wondering what size files people like to keep their plugin too, theoretically the entire plugin file gets called with myBB on each load so it has to load the entire 100kb file, it doesn't take many of these before you start hitting an MB of additional load.

As such I am thinking it may be worth splitting this into conditional includes. It isn't the tidiest method of handling stuff I will admit and is fairly over the top when a lot of the functions are only a few lines, however at what point do you guys start conditionally including to make this smaller rather than loading big files and at what point is that just over the tops and annoying for maintenence.

I am going to split the install SQL into a different file, as well as the template stuff, because that is information that only ever needs to be called at very select times and not every time the system loads. That should lighten things up a lot.

However thought this was worth a discussion.

I by no means don't want to write a php file or every function, but certainly for smaller groups of it, so each load should theoretically be only 10Kb or so at most.

Is it even worth bearing any thought?

This user has been denied support. This user has been denied support.
If you only ever need the code when misc.php?yourpage is called, you may skip the plugin part altogether and use yourpage.php instead of misc.php. That's the best solution in terms of not wasting resources by loading unnecessary code with every request. And if it's going to be huge, it's worth separating it.

On the other hand, PHP has to be able to load loads of files regardless whether they're used or not. If your PHP setup is optimized properly you may not notice a difference.
Well misc only loads my coad in that I use misc start and exit out afterwards. Its more that mybb loads up the plugins all the time. Now I only load it when a setting ia enabled the rest is all is wrapped in that condition.

Im juat thinking of breaking it down almost like classes but just files with a few functions rather than class files. It makes sense in terms of overheads and I did something similar in an online store plugin I authoured for a cms years ago with greay success. In this case I am using mybb as almost a framework and bolting on a new functionality I just dont want to use load where I dont want to but also want to leverage internal architecture where I can

Forum Jump:

Users browsing this thread: 1 Guest(s)