How can I reduce the amount of files loaded/included per plugin?

Previous versions of WordPress didn’t really provide a good means to conditionally enqueue stylesheets and JavaScript within a plugin (i.e. only when needed). So most plugin authors enqueued both on every WordPress init/load, even if the plugin wasn’t being used on a given page.

Current versions of WordPress allow for enqueuing later in the flow so you you can, for example, enqueue on your shortcode init/parse.

So you really have only a few options here:

  • Use Minify to reduce the file size and in some cases combine files to reduce the number of requests, file I/O, and bandwidth. (Already suggested by @m4t1t0)
  • Directly modify the plugins to prevent the enqueue if the plugin is not actually used on a given page.
  • Open a support ticket for the appropriate plugin and request the author to update the plugin.

Hopefully other users here might have some suggestions for you.

Leave a Comment