Search Over 30,000 FREE Plugins from the Official WordPress Plugin Directory Repository

WP-Rocket Footer JS

WordPress plugin to force all JS to the footer including inline scripts. Depends on WP-Rocket This is NOT an official addon to WP-Rocket!

This plugin will combine all inline and external JS in the order found on the page and save it to WP-Rocket's cache folder as a new file. All localized scripts are excluded and combined to one script, placed before the external script tag.

If you need dedicated/professional assistance with this plugin or just want an expert to get your site to run the fastest it can be, you may hire me at Codeable

Author Derrick Hammer
Contributors pcfreak30
Tags footer javascript, optimize, wp-rocket

This section describes how to install the plugin and get it working.

  1. Upload the plugin files to the /wp-content/plugins/rocket-footer-js directory, or install the plugin through the WordPress plugins screen directly.
  2. Activate the plugin through the 'Plugins' screen in WordPress
  3. Clear WP-Rocket cache and view HTML source!


  • Auto optimize, WP Rockets lazyload, and google analytics to use normal tags instead of javascript loaders so they can get minified
  • If minify is enabled due to LazyLoadXT or A3_Lazy_Load support, then lazy load facebook, twitter, google plus widgets, and avada google maps (if Avada_GoogleMap exists and google maps is on)
  • Enqueue LazyLoadXT widget extension if lazyload is enabled since lazy load plugins don't supply it
  • Improve lazy load regex patterns
  • Split minify to rocket_footer_js_process_remote_script and rocket_footer_js_process_locate_script functions with associated filters to hook into
  • Minify emojione in JS
  • Add hook rocket_footer_js_rewrite_js_loaders to allow pre-processing before minification
  • Add support for avada google maps lazy loading
  • Remove duplicate google maps API scripts and prioritize the first one that has an API key
  • Only lazy load google maps if there is any script content
  • Added function rocket_footer_js_lazyload_script to reduce code duplication


  • Ensure url scheme is set correctly when converting from a CDN domain


  • Disable minify on AMP pages


  • Tested on WordPress 4.7
  • Ensure PHP 5.3 compatibility


  • Correct/improve relative URL logic
  • Prevent html from being minified before JS to prevent issues with detection
  • Add new minify cache system to reduce computation time required to minify a page

Notice: This new cache system could cause unknown issues. While it has been tested, not every situation can be accounted for. Contact me if you hit a problem.

Notice: Cache is stored in transients, so only a normal wp-rocket purge will clear everything


  • Fix logic bug in data-no-minify check


  • Check for relative URL's
  • Add compatibility support for "Page Links To" since it does naughty things with buffering


  • Bugfix fetching JS from filesystem with http\Url
  • Add a newline into the automatic semicolon insertion for the case that the last text is a comment


  • Ensure zxcvbn is loaded normally and not async


  • Exclude js template script tags


  • Check for sourcemaps and add a new line to prevent syntax errors


  • Check for off in display_errors


  • Catch errors if WP_Error is returned or status code is not 200 or 304 or its empty
  • Log errors if debug mode is enabled or PHP display_errors is enabled
  • Disable minify when debug is on regardless of settings
  • Log processed scripts in debug mode
  • Move query string check to only run for local files


  • Web fetch dynamic scripts being defined as not having a JS extension
  • Add regex to remove broken conditional comments out of inline js


  • Add constant DONOTMINIFYJS and function is_rocket_post_excluded_option to minify status check


  • If file is external, we do not want to treat the response as a filesystem path
  • Always set the url domain back to home_url() because it will need to be that even if the original is a CDN or not


  • Use home URL and ABSPATH for the site root and not assume everything is in wp-content


  • Use a http_build_url shim as a fallback instead of deactivating with an error


  • Set main script tag to async


  • Minified wrong JS buffer for inline JS
  • Don't prepend semicolon since its already conditionally prepended for inline JS


  • Add detection for PHP HTTP PECL extension
  • Update code commentation and PHPDoc blocks


  • Changed logic to disable minify setting on front end and combine all scripts + minify if option is set (excluding localized scripts) to a new file in minify cache folder. File name will have user ID if logged in to be unique.
  • Keep application/ld+json in the header


  • Exclude JS extension from slug name and ensure remote file is saved with a JS extension


  • Check for CDN files in remote tags and convert back to a local filename for minification
  • Do variable cleanup


  • Initial version
Version 1.3.0

Requires WordPress version: 4.2.0 or higher

Compatible up to: 4.7.2

Last Updated 13 Feb 2017

Date Added: 27 Mar 2016

Plugin Homepage


5 stars
3 ratings


Not Enough Data

Works: 0
Broken: 0