Skip to content

Instantly share code, notes, and snippets.

@str
Last active September 22, 2015 14:57
Show Gist options
  • Save str/29a7efbbfd64358e47c6 to your computer and use it in GitHub Desktop.
Save str/29a7efbbfd64358e47c6 to your computer and use it in GitHub Desktop.
WP requeue JS and CSS to the bottom
<?php
/**
* The plugins load their JS in the header, which should not.
*/
function reQueuePlugins() {
if (!is_admin()) {
$jsLibs = [
'anything-popup-js' => get_option('siteurl').'/wp-content/plugins/anything-popup/anything-popup.js',
'jquery.scrollTo' => get_option('siteurl').'/wp-content/plugins/spider-faq/elements/jquery.scrollTo.js',
'loewy_blog' => get_option('siteurl').'/wp-content/plugins/spider-faq/elements/loewy_blog.js',
'tntscript1' => get_option('siteurl').'/wp-content/themes/nsm-seating/js/video-list-manager.min.js',
];
$cssLibs = [
'tablepress-responsive' => '/path/al/style.css';
];
foreach ($jsLibs as $name => $file) {
wp_deregister_script($name);
wp_register_script($name, $file, ['jquery'], false, true);
wp_enqueue_script($name);
}
foreach ($cssLibs as $name => $file) {
wp_dequeue_style($name);
wp_register_style($name, $file);
wp_enqueue_style($name);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment