This plugin will automatically have the CriticalCSS.com web service get the needed above the fold CSS for every page on your site to help improve your user experience and site speed. This is commonly required by google pagespeed as one of the last steps to do.
This plugin alone will not improve site performance. You need a minify and/or caching plugin as well.
If you are looking for a professional team to get your WordPress site to run faster, check us out for our speed optimization services at Rank Grow Digital
This section describes how to install the plugin and get it working.
- Upload the plugin files to the
/wp-content/plugins/criticalcssdirectory, or install the plugin through the WordPress plugins screen directly.
- Activate the plugin through the ’Plugins’ screen in WordPress
- Go to Settings -> Critical CSS, and add your API key from CriticalCSS.com.
- Where do I get an API key from?
At the time of writing (1 Jan 2017) the price for using CriticalCSS.com is:
£2/month for membership + £5/domain/month. This means the total cost will be £7/month if you use this plugin for one site.
- How do I report an issue?
You may go to https://www.github.com/pcfreak30/wp-criticalcss/issues and make a new issue. For any support, see the support forums.
- Will this work for inside paywalls or membershp sites?
Currently no. Since CriticalCSS.com can not access protected pages currently, the page must be publicaly visible to work. Means to allow this to work may come in the future.
- What will happen if I update content on the site or change my theme?
The plugins css cache will automatically purge for that post or term and get queued for processing again on the next user request of it.
- What will happen if I upgrade a plugin or theme?
The whole cache will be purged regardless of the purge setting
- Does this support any caching plugins?
Yes currently WP-Rocket is supported. Others can be added as integrations on request.
- What host is supported?
Generally any host. Some hosts like WPEngine has special support to purge the server cache.
- What is the
/nocache/in the URL’s in the queue?
This is used as a special version of the web page that forcibly disables supported caching and minify plugins to ensure that critical css is created without complications. SEO wise these URL’s are safe as they have no references anywhere and google will not be aware to crawl them.
Bidragsgivare och utvecklare
”WP Critical CSS” är programvara med öppen källkod. Följande personer har bidragit till detta tillägg.Bidragande personer
- Bug: Fix edge case with custom post types rewrite rules by putting them before the generic rules
- Bug: Don’t check for manual css to see if we need to add to queue since we can just disable the api by removing the key
- Bug: Fix forceInclude CSS selectors functionality. It was not sending the right field name to the API.
- Bug: Dont try and remove duplicate rewrite rules due to possible edge cases
- Compatibility: WP Rocket 3.4 got rid of get_rocket_purge_cron_interval, add compatibility
- Bug: Misc fixes to remove warnings with $_POST vars
- Bug: Fix what is purged in web fetch mode for the page check flag
- Bug: Remove use of compat function
- Bug: Fix slashing in saving critical css data
- Feature: Add WebP compatibility to force webp detection off no nocache requests
- Enhancement: Refactor queue logic to only process 1 item per run and don’t die after
- Enhancement: Refactor kinsta integration to use their mu-plugin for purging
- Enhancement: Refactor rewrite url logic for nocache urls based on WP Core rewrite class
- Enhancement: Enable the queue processes to run until the queue is empty with filterable delays if running in PHP CLI mode (shell)
- Enhancement: Remove the paging in the queue UI tables for simplicity
- Enhancement: Add compatibility with Kinsta caching to bust it with a query string for nocache urls
- Compatibility: Add compatibility with SEO/redirect plugins
- Compatibility: Add compatibility support for Elementor to prevent critical css from showing up on editor preview
- Bug: Prevent override of DONOTCACHEPAGE with WP Rocket
- Enhancement: Ensure that nocache pages are purged on wpengine to prevent caching
- Compatibility: Add compatibility support for Kinsta hosting
- Enhancement: Update framework
- Bug: Fix small random bugs
- Bug: Don’t check queue in content mode if we have manual or fallback CSS
- Bug: If global fallback cache is empty, ensure $fallback is false
- Bug: Ensure item data is stored correctly for meta in multisite
- Bug: Handle JOB_ONGOING status in processing
- Bug: If prioritize_manual_css is not on then set manual to false to ensure its queued
- Bug: Don’t hook wp_criticalcss_purge_cache during cron
- Bug: If remote CSS file could not be fetched, skip it instead of silently failing
- Enhancement: Add upgrade logic to clean up tables
- Enhancement: Only set CSS content hashes if no template is set in background processing
- Enhancement: Don’t show force_web_check option in template mode
- Enhancement: Only show post type, archive and taxonomy css options if manual css is on
- Enhancement: Don’t show template cache if manual css is on
- Enhancement: Don’t purge cache if manual css is on and there is no API key
- Enhancement: Only show queue and log tabs if an api key is entered
- Enhancement: Don’t purge cache if API key is empty
- Enhancement: Allow API key to be emptyued
- Enhancement: Support query vars in get_current_page_type
- Feature: Allow manual css for post types, post type archives, and taxonomies
- Feature: Add template log to track what pages have been enqueued for a template to improve purging
- Feature: Add checking for post type, post type archive, and taxonomy CSS
- Compatibility: Force wp-rocket’s critical css off
- Compatibility: Add integration with a3 lazy load to disable lazy load on nocache pages
- Bug: Fix usage of restore_current_blog being undefined
This is a MAJOR release and over 50% of the code is rewritten. While it has been extensively tested, there may still be bugs! Please test in a development site before deploying! Due to the amount of work, only a summary of this version will be detailed below.
- Major rewrite using new composer based framework.
- Feature: Added queue table for web check queue.
- Feature: Added log table which gets purged via custom cron event if there is no cache integration.
- Feature: Added ability to force styles to be included in critical css with simple names or regex.
- Feature: Added ability to give a manual CSS input for any term or post
- Feature: Added ability to have a parent hierarchical term or hierarchical custom post type override its children and force them to use its CSS. The very top parent with the override will be used. This is exposed with the manual input on editing a term or post.
- Feature: Added ability to force manual css to always be used in-place of generated css.
- Feature: Added a setting for a global CSS fallback. This is manual input only.
- Bugs: Too many to review that are fixed
- Bug: SECOND_IN_SECONDS is defined in wp-rockets compatibility code only, so must be removed
- Bug: Ensure object_id is an integer in get_permalink
- Bug: Disable rocket_clean_wpengine and rocket_clean_supercacher functions in after_rocket_clean_domain action when disabling integrations
- Enhancement: Don’t use web check transient in template mode
- Bug: Don’t clear web check flags for posts or terms on edit in template mode
- Bug: Fix the queue item exists method to only query template if it exists
- Bug: Correct data unset’s in save and update queue methods
- Bug: Don’t try adding to API queue if no template exists
- Bug: Purge all cache in template mode
- Bug: Fix missing variable assignment for get_transient call in get_item_data
Bug: Restore set_cache call accidentally removed in 0.6.0
- Bug: Fix multisite settings menu
- Feature: Add new cache mode to process pages by the wordpress template
- Feature: Add full multisite compatibilty using site transients and network wide queue tables
- Security: Prevent direct access class files
- Bug: Use get_expire_period not get_rocket_purge_cron_interval
- Bug: Replace purge lock with disable_external_integration method due to the order that the actions run
- Bug: Disable external integration when purging cache from web check queue
- Enhancement: Improve redirect_canonical logic
- Enhancement: Rebuild cache system without using SQL
- Cleanup: Clean up code and fix typo with cache
- Change: Generalize fix_woocommerce_rewrite to fix_rewrites
- Bug: Add nocache URL rewrite fix for page archives
- Tweak: Don’t append $query_string as it is generally unnecessary
- Bug: Ensure all custom taxonomies that have rewrite enabled have the nocache url enabled
- Bug: Fix woocommerce taxonomies by forcing all nocache rewrite rules for woocommerce taxonomies to the top of the rewrite rule list
- Enhancement: Added hack for WPEngine websites to prevent duplicate item entries
- Enhancement: Convert relative URL’s to absolute when doing a web check
- Bug: Add a purge_lock property with getter/setter to flag when cache is being purged due to a item completing the API queue to prevent a process infinate cycle
- Bug: Fix version comparison logic for upgrade routines and allow previous upgrade code to run on 0.4.0 upgrade due to the bug
- Enhancement: Major refactor to use dedicated mysql storage tables for queue instead of wp_options to simplify data management and ensure no duplicates can exist
- Enhancement: If $url in WP_CriticalCSS::get_permalink is a WP_Error, return false
- Enhancement: Skip item in web check queue if item exists in API queue or the permalink is false
- Cleanup: Purge all queue items from options table and web check transients on 0.4.0 upgrade
- Bug: Only set DONOTCACHEPAGE if not set
- Enhancement: If nocache is on, add robots meta for SEO to prevent duplicate content
- Bug: Add slashes with wp_slash to protect post meta with slashes
- Bug: Ensure the version setting actually updates on upgrade
- Enhancement: Prevent duplicate web request queue items by querying the serialized data from the options table
- Bug: Fix purge bulk action
- Cleanup: Merge settings classes together
- Bug: Store status information when a generate API request is made
- Enhancement: Rework elements of settings UI
- Enhancement: Add bulk purge option in queue table
- Enhancement: Queue system and core system refactor that checks for changes by hashing html and css output via web request
- Bug: after_rocket_clean_domain hook needs to be in disable_autopurge check
- Bug: Messed up 0.2.4 version number
- Change: Do not automatically auto-purge by default
- Bug: Use parse_url and http_build_url to safely append nocache in the permalink
- Bug: Allow purge through wp-rocket to work if its not through cron
- Bug: Fix timestamp logic
- Enhancement: Do not process critical css on 404 pages
- Bug: Rename more places to wp_criticalcss
- Change: Renamed options page
- Bug: Switch to using OPTIONNAME constant
- Bug: Missed places to use new class name
- Change: Rename everything to WP CriticalCSS due to legalities. This means that it will not be fully compatible with 0.1.x as all classes and options are renamed.
- Bug/Enhancement: Use a simpler means to enable nocache on the homepage thats less error prone
- Cleanup: reorder_rewrite_rules method not needed
- Bug: Revert bug fix for purging in 0.1.1 and just purge before setting cache
- Bug: Always delete pending transient if there is no fatal error
- Bug: Toggle purge plugin integration to prevent generated css from getting purged
- Enhancement: If WP_Error just return item so it will get re-attempted
- Enhancement: Add method to disable purge plugin integration
- Initial version