Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I've read many articles that says that we should not keep plugins that we don't use. Even if they are disabled, they use memory.

functions.php instead of 10 plugins?

What if i have 10 small plugins that each of them have a little function. Could I gain speed if moving the functions to the themes functions.php? If yes / no, why?

share|improve this question

5 Answers 5

up vote 5 down vote accepted

I agree with Rarst that on the optimization "to-do" list , this is low-priority.

..however, As far as I know , this statement :

This is myth and false

Is not always true . Disabled plugins DO use memory in an un-direct way . and sometimes - depending on the quality and the quantity of plugins - a lot of it too.

The reason lies in two basic facts .

1 - Plugins write data to wp-options table .

Essentially, there are two types of related data :

core data (written by wp itself, e.g. option_name = 'active_plugins';)

and "user" data (for lack of better name) - this is data that the plugin itself writes, which brings me to the second reason :

2 - many plugin authors do not optimize their plugins, especially when it is about the uninstall process. This causes the wp_options table to fill with unnecessary information. and sometimes a lot. many users think that if they "deactivate" a plugin - everything is back to normal.

..But it is not .

Unless the plugin author has included an uninstall process to clean all the garbage-data.

..But They rarely do (I myself always insist on including that option).

If you want to verify this with your own eyes - go to .

http://yoursite/wp-admin/options.php

you will see data from deactivated plugins.

Now - as we all know , a bigger DB is much heavier on the memory , and a bigger wp_options table WILL result in more memory when processing it every time you run a query . This gets worse with other "heavier" plugins that actually write new tables without cleaning them.

All this is on the theoretical level, and depends, like stated before, on the quality AND quantity of the plugins .

BTW - another thing that people ARE NOT usually aware of - is that also THEMES do the same . You can go to the options page stated above, and you will also see disabled themes in the same table . still there . (search for theme_mods_themename)

BTW2 - same goes for the abuse of "custom fields" ...

To answer your question - functions.php is better , if you know what you are doing . Otherwise - it is a marginal difference for the average site. I myself do everything on the functions.php.

share|improve this answer
1  
I agree with rarst. Disabled plugins do not use memory. What you are talking about is a completely separate issue. The footprint of an average plugin storage in the db is so minute that it would take more plugins than most install during the life of ten sites to see a db petformance hit. Let us be clear...a plugin is the WP way of abstraction. If the abstracted function is not loaded...it does not reside in memory though it might have some dormant config options in the db. I've worked on massive sites (1M+ hits on some days) and this has never been an issue ever. –  Brian Fegter Feb 2 '12 at 12:27
    
yet.. but 1m+ website servers are also much more powerful and resourceful than the average site´s shared hosting servers. call it minute , minimum, tiny or very small - it is still not NULL . –  krembo99 Feb 4 '12 at 10:19
    
well.. than you should read the comment again, especially the part where i said that i agree the fact that it is very low priority on the "to-do" list .. –  krembo99 Feb 4 '12 at 12:18
    
I think the bigger issue is for users to install quality plugins that don't litter a DB. It would be nice to have a verified plugin author status in the repo for users to at least have a guide. –  Brian Fegter Feb 4 '12 at 12:42
    
well.. go to read here : wordpress.stackexchange.com/questions/40951/… and you will see that I also think so. (and even willing to organize it) But it is off the point . this here is not a discussion board .it is a Q&A platform. I have answered a DIRECT question with technical details.. If you have a better answer to that question, instead of just voting down my answer, you should post a constructive ANSWER with BETTER technical details to support it . –  krembo99 Feb 4 '12 at 14:11

Even if they are disabled, they use memory.

This is myth and false. Disabled plugins are not loaded in PHP and use nothing (other than disk space :)

Could I gain speed if moving the functions to the themes functions.php? If yes / no, why?

It would be faster on a level that WP won't need to look up and include plugin files. However on practical level it probably won't be meaningful and noticeable improvement.

Basically as for optimization this would be very low priority thing to do.

share|improve this answer
    
I agree that on the optimization "to-do" list , this is a low-priority. however, Disabled plugins DO use memory in an un-direct way . and sometimes, a lot of it too. –  krembo99 Dec 13 '11 at 13:53

It depends what you mean by 'faster than with a plugin'.

WordPress loads plugins in earlier stage than the theme function.php page. The order is:

WP URL -> wp-config -> core functions -> plugins -> pluggables -> translations -> theme -> page content.

The most important thing about plugins is the code quality. If your plugins are coded correctly, you shouldn't worry about how many of them you have.

The follow link is a good source of information, specially the comments :-)

http://wpcandy.com/teaches/how-to-create-a-functionality-plugin

share|improve this answer
    
this is a nice article, but IMHO it say nothing about code quality. Putting a code in a plugin instead of functions.php does not guarantee code quality, and personally, will resolve maybe 5% of the problems, and in the long run will create 70% more. –  krembo99 Dec 13 '11 at 19:37
1  
--> continue from above > the author say that in "5 years we will thank him.." - seriously now - who has the same code for 5 years ??? new functions are up all the time, new theme functionality . does anyone use today functions from wordpress 1.2 ? I think there are much more important code practice to be learned .in the last year maybe 5-10% of my code is plugin-worthy long term. when viewed in the perspective of time - those so called plugins will be useless... –  krembo99 Dec 13 '11 at 19:47

Code maintainability should at least be equally important as optimization. If the functionality is supposed to go in a plugin, it should not be moved to the theme folder.

Moreover, I guess the optimization you get from simply moving the plugin files to the theme folder is futile. None of the actual plugin code gets changed anyway by doing this.

Other and better ways must exist if you really need to optimize the code.

share|improve this answer
    
+1 isn't enough for the 1st line, so... +2 –  MZAweb Dec 29 '11 at 16:18

I can't speak as to whether or not it will be faster, but if you plan on adding things to functions.php that you may want to disable in the future then plugins might be a better idea. Its much faster to disable a plugin rather than removing the code from functions.php and pushing a new update.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.