WP Asset Manager

A wordpress plugin that deactivates individual or all wp plugin styles and scripts per page to increase load time.

Author:John Burns (profile at wordpress.org)
WordPress version required:3.0.1
WordPress version tested:3.8.3
Plugin version:1.1.1
Added to WordPress repository:23-01-2014
Last updated:15-04-2014
Warning! This plugin has not been updated in over 2 years. It may no longer be maintained or supported and may have compatibility issues when used with more recent versions of WordPress.
Rating, %:100
Rated by:3
Plugin URI:https://www.twitter.com/WPAssetManager
Total downloads:1 203
Active installs:10+
plugin download
Click to start download

A wordpress plugin that deactivates individual or all wp plugin styles and scripts per page to decrease load time. Please leave a review or suggested improvements and spread the word!

Common uses

  • Contact Form 7 - CF7 will load its stylesheet and script into everypage, this plugin will restrict it to load into pages you need it for.
  • Prevent jQuery loading into every page.
  • Add/remove custom Stylesheets per page.
  • Add/remove custom JS per page.

Setup

  • Add folder to wp-content/plugins/ directory
  • Login to wp-admin
  • Go to plugins
  • Activate plugin
  • Put the following code into your themes header and footer.
  • All plugin scripts and stylesheets will be disabled by default
  • When editing a page, a new widget will appear below the MCE editor where you can enable / disable scripts.

Code

Add the following code to your themes header and footer

header.php

<?php
wp_reset_query();
global $post;
$styles_query = get_post_meta( $post->ID, '_active_styles', true );
$styles_array = unserialize($styles_query);
?>

<?php if (!empty($styles_array[0])) { foreach($styles_array as $style): ?>
<link rel="stylesheet" href="<?php echo $style; ?>">
<?php endforeach; } ?>

footer.php

<?php
wp_reset_query();
global $post;
$scripts_query = get_post_meta( $post->ID, '_active_scripts', true );
$scripts_array = unserialize($scripts_query);
?>

<?php if (!empty($scripts_array[0])) { foreach($scripts_array as $script): ?>
<script src="<?php echo $script; ?>"></script>
<?php endforeach; } ?>

Live Examples

Future Releases

  • Ability to assign custom styles and scripts to custom post types.
  • Automatically save active themes stylesheets and scripts.

Useful Links