Getting Started

Getting Started

Introduction

Installing W3Speedster

  1. Download the extension zip:
    • Download the zip provided on my account page of W3Speedster.
  2. Installing:
    • extract the zip in the root directory of your project.
  3. Add the required files:
    • Next, copy the W3speedster/EventListener folder and paste it into the src folder within the project root directory.
  4. Config the bundle:
    • Then, navigate to the project_root_directory/config folder, open the services.yaml file, and add the code as shown in the image below.
      App\EventListener\W3MiddlewareListener:
         tags:
            - { name: 'kernel.event_subscriber' }
  5. Verify Installation:
    • run the bundle to verify if everything is working as fine.

Updating W3Speedster

You can manually update the bundle. Remember, if your license has expired, you can renew it on your account page.

  1. Go to your account and download the latest version of W3Speedster
  2. Unzip the archive and then upload the ‘w3speedster’ folder to the ‘root’ directory and overwrite the existing folder

Uninstalling W3Speedster

  1. Disable the bundle:
    • Remove the bundle from root directory of your project.
  2. Remove the added files:
    • Remove the W3speedster/EventListener folder from the src folder within the project root directory.
  3. Comment on the config:
    • Remove or comment on the config line added while installing in services.yaml file from the project_root_directory/config folder
  4. Test application:
    • Verify that your application works correctly without the bundle.

What exactly does W3Speedster do?

W3Speedster is a WordPress performance optimization package with many features:

  • CDN Integration
  • HTML Caching
  • Optimize images
  • Lazy Loading
  • WebP Support
  • Minify CSS
  • Minify JavaScript
  • Defer parsing of JavaScript
  • Serve scaled images
  • Avoid CSS @import
  • Exclusions
  • Debug Site
  • Google Fonts Optimization
  • Delay JS

How to find the best settings for your site?

So, you’ve activated W3Speedster. And now you’re wondering, “How do I get the best results for my site?”

Every site has a different theme, a different set of packages, and different content. So the best settings will vary from site to site. In this article, you’ll learn the safest way to experiment with the most commonly used W3Speedster settings. The goal is always to make your site faster. And activating more options doesn’t always result in more speed. So don’t worry if you’re not able to turn everything on. To check if your site is faster, you should use a tool that tests load times. You can make use of tools like GTmetrix, Pingdom Tools, or Google Developers PageSpeed Insights to test the load times of your website and get a detailed report. It’s a good idea to take some benchmark speed tests before you begin configuration, then again after you’re done applying optimizations

Best practices for configuration

When testing options in W3Speedster, please use the following process:

  • Activate options one-at-a-time, not everything at once
  • After each option that you activate, check your site in a browser window where you are not logged in to WordPress. An incognito/private window works well. By doing this you will be able to see immediately if a particular option causes any issue.
  • Check a few types of pages on your site. If anything doesn’t look right, don’t panic! Disable the last option you activated and your site will return to normal.

Getting Started with Configuration

HTML Cache

HTML cache helps us to enable HTML minification, it servers cache via .htaccess and advanced cache files, preloading cache page per minute

General

You can enable optimization to streamline your site's resources and improve loading times. Separating the cache ensures that different versions of your site, such as mobile and desktop, are stored and served efficiently. Integrating a Content Delivery Network (CDN) helps distribute your site's content across multiple servers, speeding up delivery to users worldwide. Enabling Gzip compression reduces the size of your site's files, further improving load times. Fixing Interactive Next Paint (INP) issues enhances your site's interactivity and responsiveness. Additionally, you can remove query parameters to simplify URLs and improve caching effectiveness.

CSS > CSS Optimization

You can enable CSS Minification so that W3Speedster minifies your CSS files. You can set rules of minification and even exclude CSS files from this minification process. You can also select when to load secondary CSS and whether you want to delay it

Javascript > JS Optimization

You can enable JS Minification from this tab to instruct W3Speedster to minimize JavaScript files. You can also Defer Parsing of JavaScript in this tab and exclude JS from combining. You can also choose when you want to load combined JavaScript and how much time do you want to delay JS tags by.

Exclusion

You can preload resources such as CSS and font files to ensure they load quickly when a user visits your site. You can exclude specific images from lazy loading to ensure they display immediately. Additionally, you have the ability to exclude certain pages, CSS, and JavaScript files from optimization if needed. For resources that consume significant data, you can also force lazy loading of CSS and JavaScript to improve initial page load times.

Custom Code

You can Write custom JS/CSS code which we need to load at the time of site loading. This allows you to apply specific styles and functionalities right from the start, ensuring that your custom code is executed immediately as your website loads.

Image Optimization

You can enable Lazy Loading for images, I-frames, and videos. We recommend activating LazyLoad, because it helps reduce the negative performance impact of images, by loading them only when the visitor scrolls down the page and actually needs to see them.

You can also enable automatic optimization of images when uploaded and exclude images from optimization if you want to.
Hooks

You can write predefined custom PHP functions to perform the tasks mentioned above. This allows you to automate and customize various aspects of your site's optimization, such as loading resources, excluding elements from optimization, and managing caching. By using PHP, you can tailor these functionalities to fit your specific needs and ensure they are executed efficiently.

HTML Cache

Enable HTML Caching

W3Speedster generates and stores static HTML versions of dynamic Website pages. These cached HTML files are served directly to visitors without executing PHP or MySQL queries, thereby reducing server load and speeding up page delivery.

  • Upon the first request to a page, the plugin processes the page normally and generates a static HTML version.
  • This HTML file is stored in the cache directory.
  • Subsequent requests serve this static HTML file directly, bypassing the framework's core processing.

Enable Caching for Logged-in Users

W3Speedster enhances performance for authenticated users by enabling caching during logged-in sessions. This reduces the need to dynamically generate pages with each request:

  • Upon login, the plugin continues to cache pages for authenticated sessions if caching for logged-in users is enabled.
  • By default, many caching solutions disable this to avoid delivering personalized or sensitive data to unintended users. W3Speedster, however, offers the flexibility to allow it
  • When a logged-in user performs an action such as publishing a post or updating their profile, the plugin automatically invalidates the associated cached HTML file. A new cache is then generated on the next request, ensuring users always receive the most recent content.
  • For websites displaying role-based content (e.g., different layouts or access for subscribers and editors), W3Speedster supports per-role caching, serving role-specific HTML versions to preserve accuracy and personalization without sacrificing performance.

Serve HTML Cache File by

.htaccess: This option allows you to configure your server to serve HTML cache files directly using the .htaccess file. This method can improve page load times by delivering cached versions of your pages more efficiently. Advanced Cache File: The "Advanced Cache File" setting refers to additional configuration options for managing and optimizing cache files. This may include more granular control over caching rules, file expiration, or handling special cases to enhance performance and ensure proper cache management.

Enable Caching Page with GET Parameters

Feature:

This option enables the caching of pages that include GET parameters in their URLs (e.g., example.com/page?param=value).

Functionality:

  • When enabled, W3Speedster generates and serves cached versions of pages based on unique GET parameter values.
  • Enhances performance for dynamic and content-rich websites, such as:
    • E-commerce platforms
    • Blogs with filters or query-based navigation
    • Dynamic listing directories

W3Speedster Optimization:

  • Handles parameter-based caching with precision to avoid excessive or inaccurate cache entries.
  • Supports safe caching for parameter variations like:
    • ?utm_source=google
    • ?filter=color

Advantages:

  • Maintains content accuracy while leveraging cache efficiency.
  • Ensures quick delivery of parameterized pages.
  • Prevents bypassing of cache for URLs that differ only by non-personalized query parameters.

Cache Expiry Time

Feature:

Cache Expiry Time, also known as Cache Lifetime, refers to the duration for which a cached HTML version of a page remains valid on the server before it is considered stale and needs to be refreshed or regenerated.

Functionality:

  • W3Speedster allows you to configure the cache expiry duration manually.
  • Set the duration in seconds (e.g., 3600 seconds = 1 hour).
  • Cached HTML files are retained in the cache directory until the expiry time elapses.

W3Speedster Configuration:

  • The default expiry time is set to 3600 seconds.
  • This value can be adjusted based on:
    • Frequency of website content updates.
    • Desired balance between performance and data freshness.

Advantages:

  • Ensures cached pages are served quickly, reducing load time.
  • Automatically refreshes outdated cache, keeping content current.
  • Provides a customizable approach to cache management tailored to dynamic or static sites.

Separate Cache for Mobile

Feature:

Enables separate caching and optimized content delivery for mobile and desktop users.

Functionality:

  • W3Speedster analyzes the User-Agent string from the request header to detect the device type.
  • Based on the detection:
    • A dedicated static HTML cache file is generated for desktop users.
    • A separate static HTML cache file is generated for mobile users.

Caching Process:

  • Device type is identified server-side before PHP execution.
  • The appropriate cached HTML file (mobile or desktop) is served according to the detected device type.

Advantages:

  • Ensures optimized performance and layout delivery for different device types.
  • Reduces load time by avoiding redundant content generation.
  • Improves user experience by serving content specifically tailored for mobile or desktop use cases.

Clear Cache when Page or Post is Updated

Feature:

Ensures cached content stays synchronized with updates to your website.

Functionality:

  • When a page, post, or custom post type is updated, published, or deleted, W3Speedster:
    • Automatically removes the corresponding cached HTML file.
    • Generates and stores a fresh cache version upon the next visit.

Extended Cache Clearing:

W3Speedster also clears associated cache files to maintain content consistency:

  • Archive pages (e.g., /blog, /category/news)
  • Paginated lists affected by content updates
  • Homepage, if the updated content appears in recent posts

Advantages:

  • Prevents outdated content, summaries, or thumbnails from being displayed.
  • Ensures site-wide consistency and content freshness.
  • Enhances user experience and site reliability without manual intervention.

Preload Caching

Feature:

Proactively generates static HTML cache files before user requests, improving performance from the first visit.

Functionality:

  • W3Speedster automatically crawls and stores static versions of pages in advance.
  • Cache generation is scheduled or triggered based on predefined criteria.

How It Differs from Traditional Caching:

  • Traditional caching: Generated only on the first user visit, which involves PHP execution and database queries.
  • Preload caching: Cache is pre-warmed, eliminating delays for first-time users.

Advantages:

  • Instant page load for first-time visitors.
  • Improved Time to First Byte (TTFB).
  • Reduced server load during peak traffic.
  • Better SEO, as search engines receive faster responses.

Preload Page Caching Per Minute

Feature:

Automatically refreshes cached versions of pages at set intervals to maintain content freshness and fast load times.

Functionality:

  • W3Speedster supports configurable cache preloading intervals (e.g., every minute).
  • Designed for high-traffic or frequently updated sites, such as news portals or live data platforms.

How It Works:

  • Automatic Page Preloading: W3Speedster crawls and regenerates cached pages at fixed intervals, even if the page hasn’t been visited recently.

Benefits:

  • Fresh content for first-time visitors: Ensures visitors always access the latest version of the site.
  • Improved accuracy: Prevents outdated cache delivery, maintaining content relevance.
  • Reduced server load: Keeps cache populated, minimizing PHP/database processing.
  • SEO boost: Search engines crawl the most recent content, improving indexing and ranking.

Use Case:

  • Ideal for sites with dynamic or real-time content, ensuring accuracy without sacrificing performance.

Enable leverage browsing cache

Feature:

Caches static resources in a visitor's browser to speed up page load times and reduce server load.

Functionality:

  • Automatic Cache Control Headers: W3Speedster adds the necessary cache control headers to store static resources (like images, CSS, JS) in the browser cache for a specified duration.
  • Optimized Server Configuration: Configures the server to support local caching without manual intervention.

Benefits:

  • Faster Page Loads for Returning Visitors: Resources are served from the browser cache, improving load times on subsequent visits.
  • Reduced Bandwidth Usage and Server Load: Less server data is transferred, minimizing bandwidth and reducing server load.
  • Improved User Experience: Visitors enjoy quicker access to content, especially on repeat visits.
  • Enhanced SEO Performance: Faster load times improve search engine rankings, boosting visibility.

Outcome:

  • W3Speedster enhances both user experience and SEO performance by implementing leverage browser caching automatically, ensuring efficient content delivery and reduced load on the server.

Enable Gzip compression

Feature:

Reduces the size of files transferred between the server and the visitor’s browser to improve page load times and reduce bandwidth usage.

Functionality:

  • Automatic Gzip Compression: When enabled, W3Speedster automatically compresses text-based resources (HTML, CSS, JavaScript, JSON) before they are sent to the browser.
  • Requires Apache Server: This feature works only on servers running Apache.
  • Compression via .htaccess: Files are compressed before being transmitted, and the browser automatically decompresses them for display.

Benefits:

  • Faster Content Delivery: Reduces file sizes, leading to quicker load times for visitors.
  • Lower Bandwidth Consumption: Decreases the amount of data transferred, helping to save bandwidth.
  • Improved Page Load Speed and SEO Rankings: Faster page load speeds enhance user experience and can improve search engine rankings.

Outcome:

  • W3Speedster simplifies enabling Gzip compression, resulting in faster page loads, reduced server load, and better resource efficiency.

Remove query parameters

Feature:

Improves caching and performance by removing unnecessary query parameters from file URLs.

Functionality:

  • Interception of File Requests: W3Speedster intercepts browser requests for CSS and JavaScript files.
  • URL Normalization: Strips out query parameters (e.g., ?ver=5.7.1) from the file URLs.
  • Optimized File Delivery: The resource is served from the cache or CDN without query parameters, improving caching efficiency.

Benefits:

  • Enhanced Browser and CDN Caching: Files are easier to cache by browsers and CDNs, leading to faster load times.
  • Improved Performance: Reduces redundant requests and minimizes server load, improving site speed.
  • Better SEO: Prevents search engines from indexing the same file with different query parameters, avoiding duplicated resources.

Outcome:

  • By removing query parameters, W3Speedster optimizes the caching process, reduces network traffic, and boosts overall site performance.

Cache Path

Feature

Defines the location on your server where cached files (static HTML, JavaScript, CSS, etc.) are stored for improved performance.

Default Behavior:

  • Cache Path Management: W3Speedster automatically manages the cache path.
  • Default Location: Cached files are stored in the wp-content/cache folder.

Custom Cache Path

  • Customizable Option: W3Speedster allows you to specify a custom cache path by providing the full directory path.
  • Use Case: Useful for storing cached files in different directories or environments (e.g., separate subdomains or servers).

Benefits

  • Improved Organization: Store cached files where it best suits your site setup.
  • Enhanced Performance Optimization: Better management of cache storage locations can improve server and site performance.

Outcome:

  • W3Speedster offers flexibility by supporting both default and custom cache paths, allowing tailored caching setups to meet specific site needs.

General Settings

License Key

To use your licensed plugin, you must enter a license key. This key is unique for each product and is automatically generated when your plugin order is completed. You will find the key in the "Order Completed" email from W3Speedster. Activating the key ensures you receive updates and access to all plugin features.

Turn On Optimization

When you turn on this field, the W3Speedster Plugin will optimize your site by applying all the optimization settings. If this settings is turned off, no settings in w3speedster plugin will apply except html caching.

Optimize pages with Query parameters

This enables the optimization to be shown on the pages with query parameters when the optimization is live. For eg. https://www.example.com?nocache=1 will show optimized page if this setting is turned on. It is recommended only for servers with high performance.

Optimize pages when User Logged In

Enabling this option will optimize pages even when a user is logged in. Use this feature with caution, as it may affect the performance of dynamic or personalized content for logged-in users. Ensure that the optimization does not interfere with user-specific functionalities or content.

Separate javascript and CSS cache for mobile

This will create separate JavaScript and CSS cache for mobile. All css and javascript files will have mob.css at the end only for mobile(.css for desktop) and also separate Critical CSS will be created for Mobile and desktop.

Fix INP Issues

"Fix INP Issues" refers to addressing problems related to the "Interactive Next Paint" metric. By enabling this feature, you can resolve issues identified in Google PageSpeed Insights and/or Google Search Console related to the time it takes for your site to become fully interactive. This helps improve your website's performance and user experience.

CDN Settings

CDN URL

Enter the CDN (Content Delivery Network) URL that you have purchased for your site. This URL will be used to serve static assets like images, CSS, and JavaScript files, helping to improve your site's performance and load times by distributing content across multiple servers.

Exclude file extensions from cdn

During the implementation of the CDN, our plugin provides a section to exclude the specific extensions so that the functionality of site is not hampered, for instance, excluding ‘Font Extensions’ like (.woff, .ttf, .eot, .woff2) might be required because cross origin request for fonts are not allowed in many sites and allowing of fonts from external source has to done manually.

Exclude path from cdn

During the implementation of the CDN, our plugin provides a section to exclude the specific paths so that the work of the plugin is not hampered, for instance, excluding ‘/wp-includes/’.

Image Optimization

Optimize JPG/PNG Images

Enable image optimization by clicking the button. Once activated, images will be optimized in the background through wp-cron, provided the ‘Optimize Images via wp-cron’ option is enabled. This process helps improve your site’s performance by compressing images without losing quality.

JPG/PNG Image Quality

The W3Speedster Plugin maintains a standard image quality of 90% to preserve the clarity of your images. However, you can adjust this setting to meet your preferences, balancing image quality with file size according to your needs.

Convert to WebP

This feature will convert and render your images in the WebP format. To use it, make sure to start image optimization in the Image Optimization tab. The W3Speedster Plugin will handle the optimization for all JPG and PNG images, enhancing your site’s performance

WebP Image Quality

The W3Speedster Plugin uses a standard quality of 90% for WebP images to maintain their clarity. You can adjust this setting to suit your needs, balancing image quality with file size.

Enable Lazy Load

The W3Speedster Plugin allows you to lazy load four types of resources that can delay site loading time: Images, Iframes, Videos, and Audio. By enabling this feature, these resources will be loaded only when needed, improving your site's performance and load times.

Pixels to Load Resources Below the Viewport

The W3Speedster Plugin defaults to starting the loading of resources such as images, videos, iframes, background images, and audio when they are 200 pixels below the viewport. You can adjust this setting to start loading these resources earlier, so they appear more quickly as you scroll. For example, you can enter a value like 200 to set the distance from the viewport where loading begins.

Load SVG Inline Tag as URL

Load SVGs as URLs instead of inline tags to avoid creating large DOM elements. This approach helps improve performance by reducing the size of the DOM and simplifying your page structure.

Optimize Images via wp-cron

Enabling this option allows images to be optimized using wp-cron. The plugin will optimize one image attachment per minute to ensure that server performance remains unaffected. If you need faster optimization, click the "Start Optimization" button in the 'Image Optimization' tab to accelerate the process.

Optimize Images on the Go

This feature automatically optimizes images as site pages are crawled. The W3Speedster Plugin captures unconverted and unoptimized images when you visit a page and optimizes them in the background. This ensures that all images used on the site are prioritized for optimization. However, it is recommended to turn off this feature after the initial crawl and optimization to prevent unnecessary server load.

Automatically Optimize Images on Upload

This feature automatically optimizes and converts new images to WebP format as soon as they are uploaded. If you notice that image uploads are taking longer than expected, you may want to turn off this feature. Ensure that the settings for image optimization and WebP conversion are also enabled to use this feature effectively.

Responsive Images

The W3Speedster Plugin creates responsive images that adjust the background image of your webpage based on the user’s screen size, such as mobile, tablet, or desktop. This ensures that your images look optimal on all devices.

Insert Aspect Ratio in img Tag

This feature allows you to specify the aspect ratio for images directly within the img tag. By including the aspect ratio, you ensure that the space for the image is reserved on the page even before the image is fully loaded. This helps prevent layout shifts and improves the overall user experience by maintaining consistent image dimensions across different devices and screen sizes.

Upload Directory Path for Images

Please enter the folder path where you have the images you want to optimize. Once you enter the folder path, all images in the directory will be processed and optimized automatically. This way, images are reduced in size without any loss of quality, making them more efficient for use in web or other applications.

Calculate Image

The module will analyze and identify the images within the specified directory that require optimization. Once the directory path is provided, it will evaluate all images contained in the directory to determine which ones can be optimized for better performance. This process ensures that only relevant images are selected for optimization, streamlining the workflow and enhancing efficiency.

Start Image Optimization

By starting image optimization, the plugin will compress and optimize images on your site to enhance performance.

  • Free Version: The first 500 images will be optimized.
  • Pro Version: Unlimited images will be optimized.
Activate the Pro Version to remove the limit and optimize all images on your site.

CSS Optimization

Enable CSS Optimization

Enable this to start CSS optimiation. All css optimization like minification, critical css generation, custom css etc will show only when this option is turned on.

Combine Google fonts

The W3Speedster Plugin loads and combines all Google Fonts used on your site and loads it together preventing multiple requests. If critical css is generated, all required google fonts are loaded instantly and rest are lazyloaded ie. loads on user interaction. If you still want to load any font upfront and then you can write its css in custom css code section provided by the plugin.

Load Critical CSS

The W3Speedster Plugin generates Critical CSS which loads upfront and let all css files to load to user interaction enabling faster loading of the page.

Load Critical CSS in Style Tag

This option will load critical css in style tag instead of link tag. This option is not recommended for site with large page size. Implementing CDN will help a lot in speeding of site if this option is not enabled.

Create Critical CSS via wp-cron

Enabling this option allows the plugin to generate critical CSS for your WordPress pages using WP-Cron. By leveraging WP-Cron, the plugin can systematically process each page, creating critical CSS at a controlled pace. This method ensures that server performance remains unaffected, as the CSS generation process is spread out over time

Start generating critical CSS

This feature creates critical CSS for your website to improve page load performance. Just click on the button, it will automatically crawl almost all the pages and create critical css on its own. Critical css generation is pretty fast like 10-15 mins but may take more time with site with thousand of pages. In the Free Version, critical CSS will be generated only for the homepage. With the Pro Version (activated license key), unlimited critical CSS can be generated for your entire site.

Load Style Tag in Head to Avoid CLS

This feature allows style tags to load in the head section, fixing the Cumulative Layout Shift (CLS) of the page. To use it, simply add the ID of each style tag in the provided box and save your changes. Ensure that each style tag ID is entered on a new line.

Javascript Optimization

Enable Javascript Optimization

Enable this box to start JavaScript minification, a feature provided by the W3Speedster Plugin that optimizes your site's performance.

Lazyload Javascript

This option allows you to choose when to load JavaScript on your site. Enabling lazy loading for JavaScript can improve your site's initial loading speed by deferring the loading of JavaScript files until they are needed. Select "Yes" to enable lazy loading, or "No" to load JavaScript files immediately with the rest of your site's content. This helps balance performance and functionality based on your site's needs.

Load Javascript Inline Script as URL

Enter the matching text of the inline script URLs that you want to exclude from deferring JavaScript. Each exclusion should be entered on a new line. This allows you to specify which inline scripts should not be deferred, ensuring they load immediately to maintain essential functionality.

Exclusions

Preload Resources

If you want to preload resources such as images, CSS, JavaScript, or fonts, simply enter the complete URL of each resource in the 'Preload Resources' section. Each URL should be on a separate line. This ensures that the specified resources are loaded ahead of time, which can improve your site's performance.

Exclude Images from Lazy Loading

To prevent specific images from being lazy-loaded, you can exclude them by providing their URL, class name, ID, or alt attribute in the designated section. For example, you can enter "xyz.png" for a specific image or "nolazy" for images with a particular class name. This allows those images to load normally while others benefit from lazy loading.

Exclude Background Images from Lazy Loading

Enabling this option ensures that background images are excluded from lazy loading. This allows background images to load immediately, ensuring they are displayed without delay, which is especially important for maintaining visual consistency and providing a seamless user experience. This feature is ideal for pages where background images play a critical role in design or content presentation.

Force Lazy Load Javascript

To improve performance, you can force lazy loading for JavaScript which takes a long time to load. Enter specific words, IDs from inline script tags, or parts of script URLs in the provided section. For example, you might use identifiers like "Facebook" or "Instagram" to target and lazy load those scripts. This helps reduce loading times and improves your performance score.

Exclude Javascript Tags from Lazyload

With the W3Speedster Plugin, you can exclude specific JavaScript files from lazy loading and minification by entering their URLs in the relevant section. For example, if you have a JavaScript file like xyz.js that you do not want to lazy load or minify, simply provide its URL. This ensures those scripts are loaded normally while other scripts benefit from optimization.

Exclude Inline JavaScript from Lazy Load

This feature allows you to exclude specific inline JavaScript from being lazy-loaded. For example, you might want to exclude scripts like ‘Google Analytics’ to ensure they load immediately and function correctly without delay. This helps maintain essential functionalities while still benefiting from lazy loading for other scripts.

Exclude pages from HTML caching

Excluding specific pages from HTML caching ensures that these pages are always fetched directly from the server rather than from a cache. This approach is particularly useful for pages with dynamic content that changes frequently, user-specific pages, and sections of your site that must always display the most current data.

Exclude Pages From Optimization

To exclude specific pages from optimization, simply enter their URLs in the designated section. For example, you can list pages like /cart or /login that you do not wish to optimize. This ensures that these pages are left out of the optimization process while the rest of your site benefits from performance improvements.

Exclude Pages from CSS Optimization

To exclude specific pages from CSS optimization, enter the URL or a part of the URL where you do not want the CSS optimization to be applied. List each URL or URL fragment on a separate line to ensure those pages are excluded from the optimization process.

Exclude Page from JavaScript Optimization

With the W3Speedster Plugin, you can exclude specific pages from JavaScript minification and lazy loading by entering the script URLs or parts of the script URLs. Simply list each URL or URL fragment on a separate line. This allows you to ensure that certain pages or scripts are not affected by the optimization process.

Custom Code

Custom CSS to Load on Page Load

If you wish to preload any custom CSS that should be applied immediately when the page loads, add it in this section without including the <style> tags. This CSS will only take effect when CSS optimization is enabled, ensuring that your custom styles are loaded efficiently along with the optimized CSS.

Custom JavaScript to Load on Page Load

If you wish to preload any JavaScript, add the code in this section without including the <script> tags. Enter the JavaScript code that needs to be loaded before the page fully loads. You have two options for loading:

  • As File: Loads the script as a file.
  • Defer: Defers loading of the script until after the initial page load.
Choose the appropriate method based on your requirements to ensure optimal performance and functionality.

Custom JavaScript to Load After Page Load

If you wish to load any JavaScript after the page has fully loaded or based on user interaction, add the code in this section without including the <script> tags. This JavaScript will be executed after the page load, ensuring it does not interfere with the initial rendering of the page. Enter the JavaScript code that should run post-page load in this section.

Cache

Delete HTML Cache

Delete the HTML cache whenever you make changes to your site to ensure that the latest updates are reflected. This helps maintain accurate and up-to-date content for your visitors.

Delete JS/CSS Cache

The plugin lets you delete the combined and minified cache for JavaScript and CSS. This ensures that any changes made to your theme or plugin files are updated and reflected on your site.

Delete Critical CSS

The W3Speedster WordPress plugin allows you to delete Critical CSS. This should be done only when you make changes to the styles used in the upper part of your webpage. Deleting Critical CSS will clear the cache and require regeneration, which may take some time depending on the number of pages on your site.

Plugin Hooks

W3speedster Pre Start Optimization

Function: w3SpeedsterPreStartOptimization
Description: Modify page content pre optimization.
Parameter: $html = Content visible in pages view source.
Return: 1 – Reflect the changes done in html of the page.
function w3SpeedsterPreStartOptimization($html){
$html = str_replace('Existing content','Changed content',$html);
return $html;
}

W3speedster Before Start Optimization

Function: w3SpeedsterBeforeStartOptimization
Description: W3Speedster allows you to make changes to the HTML on your site before actually starting the optimization. For instance replace or add in html.
Parameter: $html = $html – full html of the page.
Return: 1 – Reflect the changes done in html of the page.
function w3SpeedsterBeforeStartOptimization($html){
$html = str_replace(array(""),array(""), $html);
return $html;
}

W3speedster After Optimization

Function: w3SpeedsterAfterOptimization
Description: W3Speedster allows you to make changes to the HTML on your site after the page is optimized by the plugin. For instance replace or add in html.
Parameter: $html – full html of the page.
Return: 1 – Reflect the changes done in html of the page.
function w3SpeedsterAfterOptimization($html){
$html = str_replace(array('image.png'),array('image-100x100.png'), $html);
return $html;
}

W3speedster Inner JS Customize

Function: w3SpeedsterInnerJsCustomize
Description: If you want to make changes in your inline JavaScript, W3Speedster allows you to make changes in Inline JavaScript (for instance making changes in inline script you have to enter the unique text from the script to identify the script).
Parameter: $script_text- The content of the script.
Return: $script_text – Content of the script after changes.
function w3SpeedsterInnerJsCustomize($script_text){
	if(strpos($script_text'//unique word from script//') !== false){
		$script_text = str_replace('jQuery(window)', 'jQuery(document)',$script_text);
	}
	return $script_text;
}

W3speedster Inner JS Exclude

Function: w3SpeedsterInnerJsExclude
Description: Exclude the script tag from lazy loading, which is present in the pages view source.
Parameter: $inner_js = The script tag s content is visible in the page s view source
$exclude_js_bool = 0(default) || 1
Return: 1
function w3SpeedsterInnerJsExclude($exclude_js_bool,$inner_js){
	if(strpos($inner_js,'Script text') !== false){
		$exclude_js_bool= 1;
	}
return $exclude_js_bool;
}

W3speedster Internal JS Customize

Function: w3SpeedsterInternalJsCustomize
Description: If you wish to make changes in JavaScript files, W3Speedster allows you to make changes in JavaScript Files.
Parameter: $path- Path of the JS file.
$string – javascript you want to make changes in.
Return: $string– make changes in the internal JS file.
function w3SpeedsterInternalJsCustomize($string,$path){
	if(strpos($path,'//js path//') !== false){
	$string = str_replace("jQuery(windw)", "jQuery(window)",$string);
	}
	return $string;
}

W3speedster Internal Css Customize

Function: w3SpeedsterInternalCssCustomize
Description: If you want to make changes in your CSS file, W3Speedster allows you to make changes in stylesheet files.
Parameter: $css- Css content of the file.
$path- path of css file.
Return: $css – make the required changes in CSS files.
function w3SpeedsterInternalCssCustomize($css,$path){
	if(strpos($path,' //cssPath // ') !== false){
		$css = str_replace(' ',' ',$css);
	}
	return $css;
}

W3speedster Internal Css Minify

Function: W3speedup_internal_css_minify
Description: If you don’t want to minify, W3Speedster allows you to exclude stylesheet files from minify.
Parameter: $path- path of css file.
$css- Css content of the file.
$css_minify- 0 || 1 (default)
Return: 1 – it will exclude the entered css file from minification.
0 – it will not exclude the entered css file from minification.
function w3SpeedsterInternalCssMinify($path,$css,$css_minify){
if(strpos($path,'//cssPath//') !== false){
	$css_minify = 0;
}
return $css_minify ;
}

W3speedster No Critical Css

Function: w3SpeedsterNoCriticalCss
Description: W3Speedster allows you to exclude the pages from the Critical CSS (like search pages).
Parameter: $url- Stores the url of the page.
$ignore_critical_css- 0 (default) || 1
Return: 1 – it will exclude the page you do not wish to create critical CSS.
function w3SpeedsterNoCriticalCss($url, $ignore_critical_css){
if(strpos($url,'/path/') !==false) {
	$ignore_critical_css = 1;
}	
return $ignore_critical_css;
}

W3speedster Customize Critical Css

Function: w3SpeedsterCustomizeCriticalCss
Description: If you wish to make any changes in Critical CSS, W3Speedster allows you to make changes in generated Critical CSS. For instance if you want to replace/ remove any string/URL from critical CSS (like @font-face { font-family:”Courgette”; to @font-face { )
Parameter: $critical_css- Critical Css of the page.
Return: $critical_css – Reflect the changes made in critical css.
function w3SpeedsterCustomizeCriticalCss($critical_css){
$critical_css = str_replace('@font-face { font-family:"Courgette";', ' ',$critical_css);
	return $critical_css;
}

W3speedster Disable Htaccess Webp

Function: w3SpeedsterDisableHtaccessWebp
Description: Our plugin converts .jpg/.png format to WebP format without changing the URL. it disable webp to render from HTACCESS.
Parameter: $disable_htaccess_webp- 0(default) || 1
Return: It will add w3.webp at the end of the url for instance (xyz.jpgw3.webp).
function w3SpeedsterDisableHtaccessWebp($disable_htaccess_webp){
	$disable_htaccess_webp = 1
return $disable_htaccess_webp;
}

W3speedster Customize Add Settings

Function: w3SpeedsterCustomizeAddSettings
Description: If you wish to change in variables and paths (URL), W3Speedster allows you to make changes in variables and paths with the help of this plugin function.
Parameter: $add_settings- settings of the plugin.
Return: :$add_settings – reflect the changes made in variable and path.
function w3SpeedsterCustomizeAddSettings($add_settings){
$add_settings = str_replace(array(“mob.css”),array(“mobile.css”), $add_settings);
	return $add_settings;
}

W3speedster Customize Main Settings

Function: w3SpeedsterCustomizeMainSettings
Description: Customize plugin main settings.
Parameter: $settings- Plugin main settings array (like: exclude css, cache path etc )
Return: $settings
function w3SpeedsterCustomizeMainSettings($settings){
	$settings['setting_name'] = value;
return $settings;
}

W3speedster Seprate Critical Css For Post Type

Function: w3SpeedsterCreateSeprateCssOfPostType
Description: By default our plugin creates a single critical css for post but If you wish to generate separate critical CSS for post. W3Speedster allows you to create critical CSS separately post-wise.
Parameter: $separate_post_css- Array of post types.
Return: $separate_post_css – create separate critical css for each post and page.
function w3SpeedsterCreateSeprateCssOfPostType($separate_post_css){
	$separate_post_css = array('page','post','product');
    return $separate_post_css;
}

W3speedster Seprate Critical Css For Category

Function: W3speedsterCriticalCssOfCategory
Description: W3Speedster Create seprate critical css for categories pages.
Parameter: $separate_cat_css- Array of Category.
Return: $separate_cat_css – create separate critical css for each category and tag.
function W3speedsterCriticalCssOfCategory($separate_cat_css){
	$separate_cat_css = array('category','tag','custom-category');
   return $separate_cat_css;
}

W3speedster Change Video To Videolazy

Function: w3SpeedsterVideoToVideoLazy
Description: Change video tag to videolazy tag
Parameter: $videolazy- 0(default) || 1
Return: 1 - Change video tag to videolazy tag.
function w3SpeedsterVideoToVideoLazy($videolazy){
	$videolazy= 1;
	return $videolazy;
}

W3speedster Change Iframe To Iframlazy

Function: w3SpeedsterIframetoIframelazy
Description: Change iframe tag to iframlazy tag.
Parameter: $iframelazy- 0(default) || 1
Return: 1 - Change iframe tag to iframlazy tag.
function w3SpeedsterIframetoIframelazy($iframelazy){
	$iframelazy = 1;
	return $iframelazy;
}

W3speedster Exclude Image To Lazyload

Function: w3SpeedsterExcludeImageToLazyload
Description: W3Speedster allows you to exclude the images from optimization dynamically which you don’t want to lazyload.
Parameter: $exclude_image = 0(default) || 1
$img = Image tag with all attributes
$imgnn_arr = Image tag
Return: 1 – it will lazy load the image.
0 – it will not lazy load the image.
function w3SpeedsterExcludeImageToLazyload($exclude_image,$img, $imgnn_arr){
   if(!empty($img) && strpos($img,'logo.png') !== false){
	   $exclude_image = 1
   }
   return $exclude_image;
}

W3speedster Customize Image

Function: w3SpeedsterCustomizeImage
Description: Customize image tags.
Parameter: $img = Image tag with all attributes
$imgnn = Modified image tag by plugin
$imgnn_arr = Image tag attributes array
Return: $imgnn- Customized image tags
function w3SpeedsterCustomizeImage($imgnn,$img,$imgnn_arr){
	if(strpos($imgnn,'alt') != false){
		$imgnn = str_replace('alt=""','alt="value"',$imgnn);
	}
	return $imgnn;
}

W3speedster Prevent Htaccess Generation

Function: w3SpeedsterPreventHtaccessGeneration.
Description: Our plugin converts .jpg/.png format to WebP format without changing the URL. it disable webp to render from HTACCESS.
Parameter: $preventHtaccess = 0(default) || 1
Return: 1 – It will add w3.webp at the end of the url for instance (xyz.jpgw3.webp).
function w3SpeedsterPreventHtaccessGeneration($preventHtaccess){
	$preventHtaccess = 1;
   return $preventHtaccess;
}

W3speedster Exclude CSS Filter

Function: W3SpeedsterExcludeCssFilter
Description: If you want to dynamically exclude a CSS file from optimization, W3Speedster allows you to exclude it from optimization (like style.css).
Parameter: $exclude_css – 0(default) || 1
$css_obj – link tag in object format.
$css – Content of the CSS file you want to make changes in.
$html – content of the webpage.
Return: $exclude_css – exclude CSS from optimization.
function W3SpeedsterExcludeCssFilter($exclude_css,$css_obj,$css,$html){
	if(wp_is_mobile()){
		if(strpos($css,'style.css') !== false){
			$exclude_css = 1 ;
		}
	}
	return $exclude_css;
}

W3speedster Customize Force Lazyload Css

Function: w3SpeedsterCustomizeForceLazyCss.
Description: If you wish to Force Lazyload CSS files dynamically for a specific page or pages, you can do so with the W3Speedster, it allows you to dynamically force lazyload stylesheet files (for instance font file like awesome, dashicons and css files).
Parameter: $force_lazyload_css – Array containing text to force lazyload which you have mentioned in the plugin configuration.
Return: $force_lazyload_css – Array containing text to force lazyload.
function w3SpeedsterCustomizeForceLazyCss($force_lazyload_css){
   array_push($force_lazyload_css ,'/fire-css');
   return $force_lazyload_css;
}

W3speedster External Javascript Customize

Function: W3SpeedsterExternalJavascriptCustomize
Description: If you want to make changes in your external JavaScript tags, W3Speedster allows you to make changes in external JavaScript tags.
Parameter: $script_obj – Script in object format.
$script – Content of the JS file you want to make changes in
Return: $script_obj – Make changes in Js files from an external source.
function W3SpeedsterExternalJavascriptCustomize($script_obj, $script){
if(strpos($script,'//text//') !== false){
	$script = str_replace(' ',' ',$script)
}
return $script_obj;
}

W3speedster External Javascript Filter

Function: W3SpeedsterExternalJavascriptFilter
Description: If you want to dynamically exclude a JavaScript file or inline script from optimization, W3Speedster allows you to exclude it from optimization (like revslider).
Parameter: $exclude_js – 0(default) || 1
$script_obj – Script in object format.
$script – Content of the JS file you want to make changes in.
$html – content of the webpage.
Return: $exclude_js – exclude JS from optimization.
function W3SpeedsterExternalJavascriptFilter($exclude_js,$script_obj,$script,$html){
	if(wp_is_mobile()){
		if(strpos($script,'jquery-core-js') !== false || strpos($script,'/revslider/') !== false){
			$exclude_js = 1 ;
		}
	}
	return $exclude_js;
}

W3speedster Customize Script Object

Function: W3SpeedsterCustomizeScriptObject
Description: W3Speedster allows you to customize script objects while minifying and combining scripts.
Parameter: $script_obj- Script in object format.
$script- Content of the JS file you want to make changes in
Return: $script_obj– Make changes in Js files.
function W3SpeedsterCustomizeScriptObject($script_obj, $script){
// your code
return $script_obj;
}

W3speedster Exclude Internal Js W3 Changes

Function: W3SpeedsterExcludeInternalJsW3Changes
Description: Our plugin makes changes in JavaScript files for optimization, if you do not want to make any changes in JavaScript file, W3Speedster allows you to exclude JavaScript files from the plugin to make any changes.
Parameter: $path- path of your script tags url
$string – JavaScript files content.
$exclude_from_w3_changes = 0(default) || 1
Return: 1 – Exclude the JS file from making any changes.
0 – It will not exclude the JS file from making any changes.
function W3SpeedsterExcludeInternalJsW3Changes($exclude_from_w3_changes,$string,$path){
   if(strpos($path,'//js path//') !== false){
	$exclude_from_w3_changes = 1;
   }
   return $exclude_from_w3_changes;
}

W3speedster Exclude Page Optimization

Function: W3SpeedsterExcludePageOptimization
Description: W3Speedster allows you to exclude the pages from the Optimization. if you wish to exclude your pages from optimization. (like cart/login pages).
Parameter: $html = Page viewsources content.
$exclude_page_optimization = 0(default) || 1
Return: 1 – it will exclude the page from optimization.
0 – it will not exclude the page from optimization.
function W3SpeedsterExcludePageOptimization($html,$exclude_page_optimization){
   if(!empty($_REQUEST['//Path//'])){
	$exclude_page_optimization = 1;
   }
   return $exclude_page_optimization;
}

W3speedster Customize Critical Css File Name

Function: W3SpeedsterCustomizeCriticalCssFileName
Description: If you wish to make any changes in Critical CSS filename, W3Speedster allows you to change in critical CSS file names. W3Speedster creates file names for critical CSS files but if you wish to change the name according to your preference this function will help.
Parameter: $file_name – File name of the critical css.
Return: $file_name – New name of the critical css file.
function W3SpeedsterCustomizeCriticalCssFileName($file_name){
$file_name = str_replace(' ',' ',$file_name);
	return $file_name;
}

Enable Core Web Vitals Logs


Enabling Core Web Vitals logs allows you to track and record data related to the Core Web Vitals metrics, which include Largest Contentful Paint (LCP), First Input Delay (FID), and Cumulative Layout Shift (CLS). These metrics are essential for assessing your site's performance and user experience. By logging this data, you can analyze performance issues, identify areas for improvement, and make informed optimizations to enhance overall site performance and user satisfaction.

Import / Export

Import Settings

To import settings into the W3Speedster Plugin, enter the exported JSON code from the plugin's import/export page. This allows you to apply previously saved configuration settings to your current setup, ensuring consistency and saving time when transferring settings between different sites or environments.

Export Settings

To export your settings, copy the code provided on the W3Speedster Plugin’s export page and save it in a file. This allows you to back up your configuration or transfer it to another site, ensuring that your settings can be easily restored or applied in the future.

W3Speedster
Privacy Overview

This website uses cookies so that we can provide you with the best user experience possible. Cookie information is stored in your browser and performs functions such as recognising you when you return to our website and helping our team to understand which sections of the website you find most interesting and useful.