SiteGround Optimizer – Plugin for wordpress

DOWNLOAD PLUGIN

Initially designed for SiteGround’s servers and already used by almost 2 Million SiteGround clients, with the release of SiteGround Optimizer 7.0.0 the plugin will work on any hosting platform. All WordPress users, regardless of their hosting provider, can take advantage of its unmatched WordPress speed-boosting features, no tech knowledge required.

Even though some of its features will still only work on SiteGround’s hosting platform, due to the specific server optimizations that other hosting providers might not support, the SiteGround Optimizer plugin is the most powerful all-in-one WordPress performance plugin, free and available for all.

The SiteGround Optimizer plugin has few different parts handling specific performance optimizations:

Configuration

For detailed information on our plugin and how it works, please check out our Optimizer Tutorial.

SiteGround Optimizer Dashboard Page

The Dashboard offers a quick look at the current optimization status of your website and shortcuts to the relevant optimization pages. In addition to that, since keeping your WordPress application, plugins, and themes up to date is important for your website speed and security, we’ve made sure to add a notification in the Dashboard in case your WordPress and/or plugins need an update.

SiteGround Optimizer Caching Page

On this page, you can control your website cache.

Dynamic Caching:
With our Dynamic Caching enabled all non-static resources of your website are cached to prevent unnecessary database queries and page loading, effectively decreasing the loading speed and TTFB (time to first byte) of your website. Dynamic Caching runs by default on all SiteGround servers and available only for them.

File-Based Caching:
With file-based caching enabled we will create static HTML versions of your website which will be served to future visitors. The files are stored in the browser memory.
Included in version 7.0.0, the File-Based Caching is available both for SiteGround and non SiteGround users.

File-Based Caching configuration:     - Clean up interval - this allows you to manage the interval File-Based cache will be automatically purged on.     - Preheat cache - When Preheating is enabled, our system will reload the cache once it is purged after content update in order to serve the fastest possible results to your real visitors. Preheating is using the website sitemap and being executed via cron.     - Logged-in users cache - By default, we do not cache content for logged in users. Once Logged In Cache is enabled, we will store separate caches for each user. Note, that if you have many users, the size of the stored cache may be increased. 

Memcached:
Powerful object caching for your site. Memcached stores frequently executed queries to your databases and then reuses them for better performance. It is available only on SiteGround Environment.

You can also enable Automatic Purge which will clear the cache when needed. You can use the WordPress API Cache Control checkbox if you need the WP API cache purged too.
Enabling the Browser-specific caching will create different cache versions based on the user agent used.
From Exclude Post Types you can exclude the ones you don’t want to be cached by Dynamic Caching. Feature is not available for File-Based Caching.
You can also exclude specific URLs or use a wildcard to exclude any sub-pages of a specific “parent-page”. The feature applies both for Dynamic and File-Based Caching.
We have also provided a test tool where you can check if a specific URL has Dynamic caching actually running.

We have a filter that allows you to control which user roles have access to flush the cache using the Purge SG Cache button.

Here’s an example of the code, you can add to your functions.php file:

add_filter( 'sgo_purge_button_capabilities', 'sgo_add_new_role' ); function sgo_add_new_role( $default_capabilities ) {     // Allow new user role to flush cache.     $default_capabilities[] = 'delete_others_posts'; // For Editors.     $default_capabilities[] = 'edit_published_posts'; // For Authors.      return $default_capabilities; } 

Another filter is created in order to manage the number of URLs your website will be preheating. The default value is 200.

Here’s an example of the code, you can add to your functions.php file:

add_filter( 'sg_file_caching_preheat_url_limit', 'sgo_preheat_limit' ); function sgo_preheat_limit( $xml_urls ) {     // Define custom limit for XML URL preheat.     $xml_urls = 300;      return $xml_urls; } 

Keep in mind that when modifying the file-cache related filters below, you need to flush the cache, so the sgo-config is re-generated and the filters are added to it.

If you need to add a cache bypass cookie to the default ones, you can use the following filter:

add_filter( 'sgo_bypass_cookies', 'add_sgo_bypass_cookies'); function add_sgo_bypass_cookies( $bypass_cookies ) {     // Add the cookies, that you need to bypass the cache.     $bypass_cookies[] = 'cookie_name';     $bypass_cookies[] = 'cookie_name_2';      return $bypass_cookies; } 

If you need to skip the cache for a specific query parameter, you can use the following filter:

add_filter( 'sgo_bypass_query_params', 'add_sgo_bypass_query_params'); function add_sgo_bypass_query_params( $bypass_query_params ) {     // Add custom query params, that will skip the cache.     $bypass_query_params[] = 'query_param';     $bypass_query_params[] = 'query_param2';      return $bypass_query_params; } 

If you need to add a specific query parameter which will be ignored in the cache-creation and cache-spawn processes you can do it using this filter:

add_filter( 'sgo_ignored_query_params', 'add_sgo_ignored_query_params'); function add_sgo_ignored_query_params( $ignored_query_params ) {     // The query parameters which will be ignored.     $ignored_query_params[] = 'query_param';     $ignored_query_params[] = 'query_param2';      return $ignored_query_params; } 

SiteGround Optimizer Environment Page

Here, you can force HTTPS for your site and fix insecure content errors. You can activate Database Optimization which will remove all unnecessary items from your database and optimize its tables. If you are using the InnoDB storage engine, the optimization of tables is done automatically by the engine. Use DNS-Prefetching to increase load speeds for external resources. It works by resolving the domain name, before a resource is requested. You can also manage Heartbeat Control to modify the frequency of the WP Heartbeat for different locations. By default, the WordPress Heartbeat API checks every 15 seconds on your post edit pages and every 60 seconds on your dashboard and front end whether there are scheduled tasks to be executed. With this option, you can make the checks run less frequently or completely disable them.

We have a filter that allows you to exclude specific tables from being optimized. You need to specify the table name without the database prefix.

Here’s an example of the code, you can add to your functions.php file:

add_filter( 'sgo_db_optimization_exclude', 'sgo_db_optimization_exclude_table' ); function sgo_db_optimization_exclude_table( $excluded_tables ) {     // Add tables that you need to exclude without the wpdb prefix.     $excluded_tables[] = 'table_name';     $excluded_tables[] = 'another_table_name';      return $excluded_tables; } 

SiteGround Optimizer Frontend Optimization Page

The page is split into three tabs – CSS, JAVASCRIPT and GENERAL. In the CSS tab, you can enable/disable Minification of CSS files, activate/deactivate CSS combinations to reduce the numbers of requests to the server, and also Preload Combined CSS. Here you can also exclude styles from being combined/minified.
In the JAVASCRIPT tab, you can activate/deactivate JS minification and combination so you can reduce the script sizes as well as the number of requests made to the server. You can also Defer Render-blocking JavaScript for faster initial site load. You can also exclude specific scripts from the different types of optimizations.
The GENERAL tab offers you the possibility to Minify the HTML Output, which will remove unnecessary characters and reduce data size. With the Web Fonts Optimization we’re changing the default way we load Google fonts. A preconnect link for Google’s font repository will be added in your head tag. This informs the browser that your page intends to establish a connection to another origin, and that you’d like the process to start as soon as possible. In addition, all other local fonts will be preloaded so browsers can cache and render them faster. Also when combined with CSS Combination, we will change the font-display property to swap or add it if it’s missing, so we ensure faster rendering. You can Disable Emojis support in your pages to prevent WordPress from detecting and generating emojis on your pages. You can also Remove Query Strings from static resources to improve their caching.

SiteGround Optimizer Media Optimization Page

Image Compression:
Here, you can configure the Image compression in order to resize your existing images and decrease the space they are occupying. The dimension of the images will not change. You can fine-tune the compression level as well as choose either original images backups are created. It is available only on SiteGround Environment.

Use WebP Images:
WebP is a next generation image format supported by modern browsers which greatly reduces the size of your images. If the browser does not support WebP, the original images will be loaded. It is available only on SiteGround Environment.

You can also enable or disable Lazy Load for various assets. You can also exclude specific assets such as iframes, videos, thumbnails, widgets, shortcodes and more from the dropdown menu. You have an option to exclude specific images from Lazy Loading. This is done by adding the class of the image in the tab. Enable the Maximum Image Width if you often upload large images on your website. Enabling this will resize your existing and future images whose width exceeds 2560 px.

You can modify the max image width setting using the filter we’ve designed for that purpose. Here’s an example of the code, you can add to your functions.php file:

add_filter( 'sgo_set_max_image_width', 'max_image_width' ); function max_image_width( $max_allowed_width ) {     // Add the value you want to adjust as max image width.     $max_allowed_width = 1250;      return $max_allowed_width; } 

You can modify the default Webp quality setting using the filter we’ve designed for that purpose. The default setting is 80, you can use values between 0 and 100:

add_filter( 'sgo_webp_quality', 'webp_quality' ); function webp_quality( $quality ) {     // Add the value you want to adjust as Webp image quality.     $quality = 100;      return $quality; } 

You can modify the default Webp quality type setting using the filter we’ve designed for that purpose. The default quality type is lossy which equals to 0, if you want to set it to lossless – adjust the type to 1 as follows:

add_filter( 'sgo_webp_quality_type', 'reset_webp_quality_type' ); function reset_webp_quality_type( $quality_type ) {     // Add the value you want to adjust as max image width.     $quality_type = 1;      return $quality_type; } 

SiteGround Optimizer Speed Test Page

Our performance check is powered by Google PageSpeed. Here you can check how well your website is optimized. The detailed test results will provide you with additional information on what can be optimized more.

Plugin Compatibility

If your plugin does not trigger standard WordPress hooks or you need us to purge the cache, you can use this public function in your code:

if (function_exists('sg_cachepress_purge_cache')) {     sg_cachepress_purge_cache(); } 

Preferably, you can pass an URL to the function to clear the cache just for it instead of purging the entire cache. For example:

if (function_exists('sg_cachepress_purge_cache')) {     sg_cachepress_purge_cache('https://yoursite.com/pluginpage'); } 

You can exclude styles from being combined and minified using the filters we’ve designed for that purpose. Here’s an example of the code, you can add to your functions.php file:

add_filter( 'sgo_css_combine_exclude', 'css_combine_exclude' ); function css_combine_exclude( $exclude_list ) {     // Add the style handle to exclude list.     $exclude_list[] = 'style-handle';     $exclude_list[] = 'style-handle-2';      return $exclude_list; }  add_filter( 'sgo_css_minify_exclude', 'css_minify_exclude' ); function css_minify_exclude( $exclude_list ) {     // Add the style handle to exclude list.     $exclude_list[] = 'style-handle';     $exclude_list[] = 'style-handle-2';      return $exclude_list; } 

You can exclude script from being minified using the filter we’ve designed for that purpose. Here’s an example of the code, you can add to your functions.php file:

add_filter( 'sgo_js_minify_exclude', 'js_minify_exclude' ); function js_minify_exclude( $exclude_list ) {     $exclude_list[] = 'script-handle';     $exclude_list[] = 'script-handle-2';      return $exclude_list; } 

You can exclude script from being combined using the filter we’ve designed for that purpose. Here’s an example of the code, you can add to your functions.php file:

add_filter( 'sgo_javascript_combine_exclude', 'js_combine_exclude' ); function js_combine_exclude( $exclude_list ) {     $exclude_list[] = 'script-handle';     $exclude_list[] = 'script-handle-2';      return $exclude_list; } 

You can exclude an external script from being combined using the filter we’ve designed for that purpose. Here’s an example of the code, you can add to your functions.php file:

add_filter( 'sgo_javascript_combine_excluded_external_paths', 'js_combine_exclude_external_script' ); function js_combine_exclude_external_script( $exclude_list ) {     $exclude_list[] = 'script-host.com';     $exclude_list[] = 'script-host-2.com';      return $exclude_list; } 

You can exclude inline script from being combined using the filter we’ve designed for that purpose. Here’s an example of the code, you can add to your functions.php file:

add_filter( 'sgo_javascript_combine_excluded_inline_content', 'js_combine_exclude_inline_script' ); function js_combine_exclude_inline_script( $exclude_list ) {     $exclude_list[] = 'first few symbols of inline content script';      return $exclude_list; } 

You can exclude script from being loaded asynchronously using the filter we’ve designed for that purpose. Here’s an example of the code, you can add to your functions.php file:

add_filter( 'sgo_js_async_exclude', 'js_async_exclude' ); function js_async_exclude( $exclude_list ) {     $exclude_list[] = 'script-handle';     $exclude_list[] = 'script-handle-2';      return $exclude_list; } 

You can exclude url or url that contain specific query param using the following filters:

add_filter( 'sgo_html_minify_exclude_params', 'html_minify_exclude_params' ); function html_minify_exclude_params( $exclude_params ) {     // Add the query params that you want to exclude.     $exclude_params[] = 'test';      return $exclude_params; }  add_filter( 'sgo_html_minify_exclude_urls', 'html_minify_exclude' ); function html_minify_exclude( $exclude_urls ) {     // Add the url that you want to exclude.     $exclude_urls[] = 'http://mydomain.com/page-slug';      return $exclude_urls; } 

You can exclude images from Lazy Load using the following filter:

add_filter( 'sgo_lazy_load_exclude_classes', 'exclude_images_with_specific_class' ); function exclude_images_with_specific_class( $classes ) {     // Add the class name that you want to exclude from lazy load.     $classes[] = 'test-class';      return $classes; } 

You can exclude specific post type from Lazy Load using the following filter:

add_filter( 'sgo_lazy_load_exclude_post_types', 'exclude_lazy_load_from_post_type' ); function exclude_lazy_load_from_post_type( $post_types ) {     // Add the post type that you want to exclude from using lazy load.     $post_types[] = 'post-type';      return $post_types; } 

You can exclude a specific url from Lazy Load using the following filter:

add_filter( 'sgo_lazy_load_exclude_urls', 'exclude_lazy_load_for_url' ); function exclude_lazy_load_for_url( $excluded_urls ) {     // Add the url that you want to exclude from using lazy load.     $excluded_urls[] = 'http://mydomain.com/page-slug';      return $excluded_urls; } 

With these new filters you can exclude specific assets from being lazy loaded. Keep in mind that using those filters can reduce perfomance in some cases.

You can use this filter for excluding specific images by adding their source url:

add_filter( 'sgo_lazy_load_exclude_images', 'exclude_images_from_lazy_load ); function exclude_images_from_lazy_load( $excluded_images ) {     // Add the src url of the image that you want to exclude from using lazy load.     $excluded_images[] = 'http://mydomain.com/wp-content/uploads/your-image.jpeg';      return $excluded_images; } 

You can use this filter for excluding specific videos by adding their source url:

add_filter( 'sgo_lazy_load_exclude_videos', 'exclude_videos_from_lazy_load ); function exclude_videos_from_lazy_load( $excluded_videos ) {     // Add the src url of the video that you want to exclude from using lazy load.     $excluded_videos[] = 'http://mydomain.com/wp-content/uploads/your-video.mp4';      return $excluded_videos; } 

You can use this filter for excluding specific iframe by adding their source url:

add_filter( 'sgo_lazy_load_exclude_iframe', 'exclude_iframe_from_lazy_load ); function exclude_iframe_from_lazy_load( $excluded_iframe ) {     // Add the src url of the iframe that you want to exclude from using lazy load.     $excluded_iframe[] = 'http://mydomain.com/wp-content/uploads/iframe-src.mp4';      return $excluded_iframe; } 

WP-CLI Support

In version 5.0 we’ve added full WP-CLI support for all plugin options and functionalities.

Caching:
* wp sg optimize dynamic-cache enable|disable – enables or disables Dynamic caching rules
* wp sg optimize file-cache enable|disable – enables or disables File caching rules
* wp sg memcached enable|disable – enables or disables Memcached
* wp sg optimize autoflush-cache enable|disable – enables or disables Automatic Purge cache option
* wp sg optimize purge-rest-cache enable|disable – enables or disables Automatic Purge for WordPress API cache
* wp sg purge (url) – purges the Dynamic, File-based and Object caches for the site or a single url (if passed)
* wp sg optimize mobile-cache enable|disable – enables or disables Browser caching rules

Environment:
* wp sg forcehttps enable|disable – enables or disables HTTPS for your site
* wp sg optimize fix-insecure-content enable|disable – enables or disables Insecure Content Fix
* wp sg heartbeat frontend|dashboard|post --frequency= – Adjust Heartbeat control frequency for a specific location
* wp sg dns-prefetch add|remove|urls – add, remove or list urls in the DNS Prefetch list.
* wp sg optimize database-optimization enable|disable – enables or disables the DB Optimization

Frontend:
* wp sg optimize css enable|disable – enables or disables CSS minification
* wp sg optimize combine-css enable|disable – enables or disables CSS combination
* wp sg optimize preload-combined-css enable|disable – enables or disables Preload Combined CSS
* wp sg optimize js enable|disable – enables or disables JS minification
* wp sg optimize combine-js enable|disable – enables or disables JS combination
* wp sg optimize js-async enable|disable – enables or disables Defer Render-blocking JavaScript option
* wp sg optimize html enable|disable – enables or disables HTML minification
* wp sg optimize web-fonts enable|disable – enables or disables Web Fonts Optimization
* wp sg optimize querystring enable|disable – enables or disables query strings removal
* wp sg optimize emojis enable|disable – enables or disables stripping of the Emoji scripts

Media:
* wp sg images --compression-level= – adjusts images optimization compression level – should be set as follows: 0 for Disabled, 1 for Low(25%), 2 for Medium(60%), 3 for High(85%)
* wp sg optimize backup-media enable|disable – enables or disables Backup Media option
* wp sg optimize webp enable|disable – enables or disables WebP image optimization
* wp sg optimize lazyload enable|disable – enables or disables Lazy loading of images
* wp sg optimize resize-images enable|disable – enables or disables Maximum Image Width optimization

Others:
* wp sg settings export – exports the current plugin settings
* wp sg settings import --hash= – imports plugin settings and applies them
* wp sg status (optimization option) – returns optimization current status (enabled|disabled)

Available wp sg status options

  • dynamic-cache|autoflush|browser-caching|file-cache
  • memcache
  • ssl|ssl-fix
  • database-optimization
  • html|js|css
  • combine-css|combine-js
  • js-async
  • google-fonts
  • querystring
  • emojis
  • webp
  • lazyload-images

Requirements

In order to work correctly, this plugin requires that your server meets the following criteria:

  • WordPress 4.7
  • PHP 7.0+

Our plugin uses a cookie in order to function properly. It does not store personal data and is used solely for the needs of our caching system.

Credits

Photo credits to Anna Shvets https://www.pexels.com/@shvetsa

SOURCE: WORDPRESS.ORG
THU HUYỀN – LINKPIZ.COM
ORIGINAL LINK

SHARE
By Linkpiz.com

Leave a Reply

No widgets found. Go to Widget page and add the widget in Offcanvas Sidebar Widget Area.