Deactivated W3TC lazy loading and rely on Wordpress' own lazy loading

approach to enable images for non-JS users.
This commit is contained in:
2026-07-29 12:44:34 +02:00
parent 96d985b06b
commit 7e9ce22bc7
2 changed files with 16 additions and 2 deletions
+14
View File
@@ -40,6 +40,20 @@ function c1024_2026_assets() {
// Load public assets through WordPress so dependencies and plugin integrations remain ordered. // Load public assets through WordPress so dependencies and plugin integrations remain ordered.
add_action( 'wp_enqueue_scripts', 'c1024_2026_assets' ); add_action( 'wp_enqueue_scripts', 'c1024_2026_assets' );
/**
* Keep W3 Total Cache from converting every image into a JavaScript-only placeholder.
*
* Native browser lazy loading can still be enabled elsewhere, but W3TC's output-buffer
* mutator removes `src` entirely and therefore prevents images from working without JS.
*/
function c1024_2026_disable_w3tc_javascript_lazyload( $can_process ) {
$can_process['enabled'] = false;
$can_process['reason'] = 'Commander1024 theme preserves non-JavaScript image delivery';
return $can_process;
}
add_filter( 'w3tc_lazyload_can_process', 'c1024_2026_disable_w3tc_javascript_lazyload' );
function c1024_2026_block_editor_assets() { function c1024_2026_block_editor_assets() {
// Load the complete canvas stylesheet inside Gutenberg's editor iframe. // Load the complete canvas stylesheet inside Gutenberg's editor iframe.
wp_enqueue_style( 'c1024-2026-editor-style', get_theme_file_uri( '/editor-style.css' ), array(), '1.0.0' ); wp_enqueue_style( 'c1024-2026-editor-style', get_theme_file_uri( '/editor-style.css' ), array(), '1.0.0' );
+2 -2
View File
@@ -5,8 +5,8 @@ Description: A clean, retro-tech inspired classic WordPress theme.
Author: Commander1024 Author: Commander1024
Version: 1.0.0 Version: 1.0.0
Text Domain: c1024-2026 Text Domain: c1024-2026
License: GNU General Public License v2 or later License: GNU General Public License v3
License URI: https://www.gnu.org/licenses/gpl-2.0.html License URI: https://www.gnu.org/licenses/gpl-3.0.html
*/ */
/* Self-hosted typefaces: keep these paths relative to the theme stylesheet. */ /* Self-hosted typefaces: keep these paths relative to the theme stylesheet. */