Performance: Plugin file structure
This affects page load speed and initial rendering by controlling how plugin files are loaded and executed.
<?php /* Plugin Name: Efficient Plugin */ function load_plugin_files() { if (is_admin()) { include 'admin-functions.php'; } else { include 'public-functions.php'; } } add_action('plugins_loaded', 'load_plugin_files'); ?>
<?php /* Plugin Name: Slow Plugin */ include 'all-functions.php'; include 'all-scripts.php'; include 'all-styles.php'; ?>
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Load all plugin files unconditionally | N/A (server-side) | N/A | Increases server response time | [X] Bad |
| Load plugin files conditionally based on context | N/A (server-side) | N/A | Reduces server response time | [OK] Good |
my-plugin/
my-plugin.php
includes/
functions.php
assets/
style.css
script.jsplugin-folder/
plugin-folder.php
includes.php
assets/
style.cssPass the test and this pattern moves unknown