Preload Links

🚀 Available from WP Rocket 3.7

In this Article

About this feature

Preloading links will improve the perceived loading time of pages for a user navigating your site. If a user hovers over, or touches, a link for 100ms or more, the HTML of that page will be fetched in the background, so that when they actually click the link, the page will appear to load nearly instantly!

This option only improves the user experience and perceived load time - you will not notice any difference in your PageSpeed score or loading time as measured by Pingdom, GT Metrix etc.

This optimization is applied on all pages - both cached and uncached.

Heads up! This feature is supported by Chrome and Chromium-based browsers. Other browsers may support this feature in the future.

Preloading links in action

The gif below demonstrates this feature in action:

Automatic exclusions

We automatically exclude some URLs from this feature to prevent unexpected results:

  • Any URL from wp-admin, login/logout
  • URLs excluded from cache by WP Rocket configuration
  • Images
  • Links with a query string or an anchor
  • External URLs

Manual exclusions

You can manually exclude URLs from this feature by adding a snippet like this to your theme's  functions.php file:

add_filter( 'rocket_preload_links_config', 'rocket_exclude_preload_links');

function rocket_exclude_preload_links( $config ) { 
	$config['excludeUris'] = 'https://www.example.com/first-url-to-exclude';
	$config['excludeUris'] = 'https://www.example.com/second-url-to-exclude';
	return $config;
}

You can add as many URLs as you want in $config['excludeUris'], to add more exclusions you can add as many lines as you need, one per URL.

When the Preload Links feature is active it will also preload links to your files, such as *.doc, *.docx, etc. This can cause errors in your error log because Preload Links will consider these as URLs and it will append the / at the end of the link. To prevent this, you will have to exclude troubled file types from the Preload Links.

📝 Manual code edit required before use!

📥   Download (.zip): WP Rocket | Regex Exclusions
Developers: You can find the code for this plugin on GitHub.

  1. Download the helper plugin zip file, then un-zip it.
  2. Open the PHP file in a text editor.
  3. On line 36 specify the file type you want to exclude from the Preload, like this: $uri[] = '(.*).doc';
  4. Re-zip the folder.
  5. Install the helper plugin on your site - go to Plugins > Add New > Upload plugin and select the zip file.
  6. Activate the plugin.

Plugin compatibility

This feature replaces the need for the following plugins and if they are detected, you will be prompted to deactivate them:

  • instant.page
  • Flying Pages
  • Quicklink
Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.