
PhastPress automatically optimizes your site for the best possible performance.
PhastPress uses advanced techniques to manipulate your pages, scripts, stylesheets and images to significantly improve load times. It’s designed to conform to Google PageSpeed Insights and GTmetrix recommendations and can improve your site’s score dramatically.
PhastPress’ motto is no configuration. Install, activate and go!
PhastPress has the Phast web page optimisation engine by Albert Peschar and Milko Kosturkov at its core.
Image optimization:
Asynchronous scripts and stylesheets:
Get the full power of Phast for your website by installing PhastPress now.
No. You do not need any other plugins, such as image optimization (e.g., Smush) or file minification (e.g., Autoptimize) after you install PhastPress, because PhastPress includes all necessary optimizations.
I recommend using the simple combination of PhastPress and WP Super Cache only. This reduces the potential for plugin conflicts, and it is really all you need.
Fast Velocity Minify is not compatible with PhastPress, and causes PhastPress not to work. Please use either plugin, but not both.
Caching means saving the HTML from the first visit to a page for later visits, so it does not have to be generated each time. Caching also helps performance with PhastPress, because the page needs to be optimized only once. It is recommendable to use a caching plugin with PhastPress.
PhastPress is not a caching plugin. I recommend using WP Super Cache in combination with PhastPress to speed up your server response time (TTFB).
In case you are using another caching plugin, please read the notes below:
WP Fastest Cache: Compatible with PhastPress, but non-caching optimizations must be disabled. Turn off the WP Fastest Cache options in this screenshot.
W3 Total Cache: Compatible with PhastPress, but non-caching optimizations must be disabled. Specifically, the Prevent caching of objects after settings change option causes problems.
Cache Enabler (by KeyCDN): Not compatible with PhastPress. Cached pages will not be optimized.
Generally, PhastPress should be compatible with other caching plugins as well. Some caching plugins include optimizations of JavaScript, CSS and/or images. I recommend turning off all optimizations to avoid conflicts with PhastPress.
Yes. The core functionality of Asset CleanUp: Page Speed Booster complements PhastPress by removing unused JavaScript and CSS from the page.
Do not use Asset CleanUp’s features for optimizing CSS and JS. These features can cause conflicts with PhastPress, and they are not needed, because PhastPress already does this.
You might be using a plugin that compresses the page before PhastPress processes it. When that happens, PhastPress cannot apply optimizations.
For example, if you are using the Far Future Expiry Header plugin, disable the option “Enable Gzip Compression”.
The “Fully Loaded Time” in GTmetrix is the amount of time taken until all network activity ceases. This measurement can be misleading because it does not take into account the order in which resources load.
Normally, external resources such as scripts and stylesheets must be downloaded, parsed and executed before the page can be rendered. PhastPress changes this sequence by including all necessary resources (that is, the critical CSS) in the page, and executing scripts asynchronously, so that they do not block the rendering of the page.
This causes the page to be visible earlier in the browser, but does not change GTmetrix’s fully loaded time.
In order to see this effect, register and log in to GTmetrix and enable the “Video” option. Then test your site (with Phast enabled), and use the “Compare” button to again test your site, but while appending “?phast=-phast” to the URL (eg, https://example.com/?phast=-phast). When the comparison loads, select the “Filmstrips” tab and you’ll see the difference. The Phast-optimized version of your site should start rendering much earlier.
Should you need to disable PhastPress on certain pages, you can use the following code to do so:
add_filter('phastpress_disable', '__return_true'); Make sure that this code runs during template_redirect or earlier.
Add this code to your theme’s functions.php, or to a new file in wp-content/mu-plugins:
add_filter('phastpress_disable', function ($disable) { return $disable || is_cart() || is_checkout(); }); PhastPress uses filesize and modification time information to detect file changes, so clearing the cache is generally not needed. When you change a script or CSS file, the change should be visible immediately after reloading.
If you do want to clear the cache, you can delete all the data inside wp-content/cache/phastpress or wp-content/plugins/phastpress/cache.
By default, PhastPress delays the load of all scripts until after the DOM has finished loading, so that the browser can render the page as quickly as possible. If you wish to load specific scripts as soon as possible, such as Google Analytics, you may add the data-phast-no-defer attribute to the script. It would be preferable to also mark external scripts as async, when possible.
For example:
<script data-phast-no-defer> // my script goes here </script> Or:
<script async data-phast-no-defer src="http://url.to.my.script/"></script> If you (or a plugin) are using wp_enqueue_script to add the script to the page, you can use the phast_no_defer data key to stop PhastPress from processing the script:
wp_script_add_data('my_script_name', 'phast_no_defer', true); Make sure this is run after registering the script. If you are trying to apply this to a script loaded by a plugin, you could use the wp_print_scripts hook:
add_action('wp_print_scripts', function () { wp_script_add_data('my_script_name', 'phast_no_defer', true); }); If you use the HTML source code to find the script name, note that -js and -js-extra are not part of the name. For example, for a script like <script id="jquery-core-js"> in the source code, the script name is jquery-core, and that is what you should pass to wp_script_add_data.
This is applied automatically for these scripts:
Images are optimized using a free API, provided by the creator of PhastPress.
During image optimization, the following data is sent to the API:
Images are sent to the API only once. Processed images are stored locally, and not retained by the API.
If image optimization is switched off, the API will not be used.
Your theme or a plugin is trying to send HTTP headers after the page has started rendering and bytes have been sent to the browser. This is wrong, but it works when PHP output buffering is enabled.
PhastPress always sends output as soon as possible, to reduce the time to first byte. That means this problem cannot be fixed without slowing down sites without buggy themes/plugins.
To fix the problem on your site, the following code needs to be run in order to enable output buffering:
<?php add_action('template_redirect', function () { ob_start(); }); You can add this code to your theme’s functions.php, or create a file output-buffer.php in wp-content/mu-plugins with the above code. You may have to create this directory first.
Alternatively, download output-buffer.zip and extract the contents into your web folder. You should end up with a file named output-buffer.php in wp-content/mu-plugins.
Yes. Add these two lines to your .htaccess file:
RewriteCond %{REQUEST_FILENAME} -f RewriteRule ^wp-content/.*[^/]\.(jpe?g|gif|png)$ wp-content/plugins/phastpress/phast.php [L,NC,E=PHAST_SERVICE:images] Then in PhastPress settings, disable image optimization in tags and CSS.
Now, reload your site and check if images are optimized.
Yes, as long as you use a CSP with a script-src policy containing nonce-*. To enable Phast’s support for CSP implement the phastpress_csp_nonce filter:
<?php add_filter('phastpress_csp_nonce', function () { return 'my-nonce'; }); Cloudflare does not support Vary: Accept, so sending WebP via Cloudflare can cause browsers that don’t support WebP to download the wrong image type. You can try using Cloudflare Polish instead.
WITHOUT ROWID.Updated Phast to version 1.110 to support versions of SQLite without WITHOUT ROWID support.
\Requests to \WpOrg\Requests\Requests class.wp-load.php as soon as WPINC is defined.Update Phast to version 1.109:
Update Phast to version 1.108:
phastpress_disable if unconfigured.Update Phast to version 1.107:
<meta charset> tags.Update Phast to version 1.106:
Content-Type: application/json header on bundler responses.X-Robots-Tag header.Update Phast to version 1.105:
X-Robots-Tag: none header on bundler responses to prevent search engines from indexing them.nonce attributes to script tags generated by PhastPress itself.PhastPress now requires WordPress 5.7 or later.
phastpress_csp_nonce filter.Update Phast to version 1.104:
Update Phast to version 1.103:
Update Phast to version 1.102:
module scripts. This fixes compatibility with Presto Player.Update Phast to version 1.101:
This release misses a file. Please use 1.123 instead.
Update Phast to version 1.100:
Update Phast to version 1.99:
async, defer attributes with data-phast- to please W3C validator.Update Phast to version 1.98:
Update Phast to version 1.97:
phast.php. This would allow a malicious person to redirect someone to a third-party site via phast.php by sending them a link. This can enable phishing attacks if the user is mislead by the hostname of the initial URL. It does not compromise the security of your site itself.Update Phast to version 1.96:
document.currentScript for scripts that are executed normally. This prevents some scripts from seeing the wrong currentScript accidentally.Update Phast to version 1.95:
<img> element src when it has a rev-slidebg class and points to transparent.png. This is because Revolution Slider‘s JavaScript depends on the image filename for its logic.Update Phast to version 1.94 to support this improvement.
Update Phast to version 1.93:
{".Update Phast to version 1.92:
url() in CSS. Eg, url( 'file.jpg' ) is notUpdate Phast to version 1.91:
document.readyState a warning rather than an error, to avoid spurious complaints from PageSpeed Insights.Update Phast to version 1.90:
phastpress_optimize_snippet function to allow arbitrary HTML to be optimized.Update Phast to version 1.89:
Update Phast to version 1.88:
PATH_INFO calculation if the environment variable is missing. This is now determined by splitting the path component of REQUEST_URI on .php/.phast.php isn’t doing it’s job.Update Phast to version 1.87:
Update Phast to version 1.86:
text/plain MIME type for the bundled CSS and JS responses. This helps apply automatic response compression in some server configurations (specifically o2switch).Update Phast to version 1.85:
Update Phast to version 1.84:
Update Phast to version 1.83:
Update Phast to version 1.81:
Update Phast to version 1.80:
init hook if WP Super Cache late init is enabled. This fixes PhastPress optimizations being done on every load in WP Super Cache’s Simple mode, and not being done at all in Expert mode.Update Phast to version 1.79:
document.currentScript in optimized scripts. (This fixed compatibility with PDF Embedder.)ob_end_clean.Update Phast to version 1.78:
<!doctype html ...> declarations correctly, and don’t insert <meta charset> before them. (This broke pages using old XHTML doctypes.)Update Phast to version 1.77:
<meta charset=utf-8> tag right after <head> and remove existing <meta charset> tags. This fixes an issue where the <meta charset> tag appears more than 512 bytes into the document, causing encoding issues.Update Phast to version 1.76:
Update Phast to version 1.75:
/) into bundler URLs in order to avoid Apache’s 255 character filename limit.Update Phast to version 1.74:
document.write from async or defer scripts, in line with normal browser behaviour.phast_no_defer script attribute to scripts generated by wp_localize_script.bootstrap.php, low-php-version.php and files in classes directory. This is not a security risk, but could generate errors.width/height attributes on img tags.Update Phast to version 1.71.
Update Phast to version 1.70.
Update Phast to version 1.69.
__p__ filename twice.Update Phast to version 1.68.
Update Phast to version 1.67.
Update Phast to version 1.66.
<link onload="media='all'"> to <link media="all"> before inlining.media attribute on generated style tags if it is all.Update Phast to version 1.65.
Update Phast to version 1.64.
Update Phast to version 1.63.
Update Phast to version 1.62.
loading=lazy attribute). This is enabled by default.Update Phast to version 1.61.
phast.php. This might help to fix issues on hosts that compress already compressed responses.Update Phast to version 1.60:
#whatever) in CSS.Update Phast to version 1.58:
Update Phast to version 1.55:
<body> tag.<meta> tags.Update Phast to version 1.54:
Update Phast to version 1.53:
Update Phast to version 1.51:
Update Phast to version 1.50:
link elements with empty href, or one that consists only of slashes.</style inside inlined stylesheets with </ style to prevent stylesheet content ending up inside the DOM.font-swap: block for Ionicons.Update Phast to version 1.49:
Update Phast to version 1.48:
Update Phast to version 1.47:
data-src, data-srcset, data-wood-src and data-wood-srcset attributes on img tags.This release should have updated Phast to version 1.47, but didn’t, by accident.
Update Phast to version 1.46:
cdnjs.cloudflare.com for CSS processing.Update Phast to version 1.45:
font-display: block for icon fonts (currently Font Awesome, GeneratePress and Dashicons).Update Phast to version 1.44:
data-pagespeed-no-defer and data-cfasync="false" attributes on scripts for disabling script deferral (in addition to data-phast-no-defer).data-{phast,pagespeed}-no-defer and data-cfasync attributes in place to aid debugging.Update Phast to version 1.43:
Update Phast to version 1.42:
Update Phast to version 1.41:
Update Phast to version 1.40:
Update Phast to version 1.39:
Update Phast to version 1.38:
Update Phast to version 1.37:
<script> tag with a blob URL, instead of using global eval, so that global variables defined in strict-mode scripts are globally visible.Update Phast to version 1.36:
Update Phast to version 1.35:
phastpress_disable hook is now triggered during template_redirect instead of plugins_loaded, which allows you to use many more functions in your hook handlers.Update Phast to version 1.34.
Update Phast to version 1.33:
<!-- ... -->) from inline scripts.Content-Length header for images.Update Phast to version 1.31:
service-config-* files for AppArmor compatibility, if there’s a rule that prevents writing *.php files.Update Phast to version 1.29:
src=hxxp://....Update Phast to version 1.28:
Vary:
Accept, so sending WebP via Cloudflare can cause browsers that don’t supportUpdate Phast to version 1.26:
id attributes on style elements. (This fixes compatibility with css-element-queries.)Update Phast to version 1.25:
Update Phast to version 1.24:
wp-load.php instead of wp-config.php.Update Phast to version 1.23:
Update Phast to version 1.22:
Update Phast to version 1.21:
Update Phast to version 1.20:
type to quiet W3C validator.Update Phast to version 1.18:
fill: url(#destination).Update Phast to version 1.17:
script attributes in sorted order (that is, src before type) to stop Internet Explorer from running scripts twice when they have src and type set.phastpress_disable hook.Update Phast to version 1.16:
Update Phast to version 1.15:
document.write. This restores normal browser behaviour.Update Phast to version 1.14:
document.write now immediately inserts the HTML into the page. This fixes compatibility with Google AdSense.Update Phast to version 1.13.1:
Update Phast to version 1.12.2:
Update Phast to version 1.12.1:
Update Phast to version 1.12.0:
data-lazy-src and data-lazy-srcset on img, source tags for compatibility with lazy loading via BJ Lazy Load, possibly other plugins.Update Phast to version 1.11.0:
src attribute from scripts that are loaded through the bundler, so that old versions of Firefox do not make extraneous downloads.Update Phast to version 1.9.3:
<!-- comments in inline scripts are removed only at the beginning.Update Phast to version 1.9.2:
Update Phast to version 1.9.1:
Update Phast to version 1.9.0:
__p__.js is appended to service requests to trick Cloudflare into caching those responses.This release was built with a pre-release version of Phast 1.9.0 that caused incorrect triggering of the browser load event. Please upgrade to PhastPress 1.8.1.
This version was based on Phast 1.5.0.