Hi there,
Thank you for providing the details about the issue you’re encountering with Jetpack Boost’s “defer non-essential javascript” feature and your website’s behavior, particularly concerning the loading of no_photo.gif.
From your description, it seems that the ImgError function, which should handle the case when an image fails to load, is not available at the time it’s needed because the script containing this function is being deferred.
One possible workaround would be to exclude that specific script from being deferred. For details of how to do that, please see our FAQ, specifically the section about How do I exclude some JavaScript files from being deferred?
Please try excluding that script and test if the issue with the image loading persists.
If you require further assistance or if this workaround does not resolve your issue, please reply in this thread with the outcomes and any additional details you can provide.
Hi @mikeeddie,
Do you have updates about that? We usually close inactive threads after one week of no movement, but we want to make sure we’re all set before marking it as solved. Thanks!
Unfortunately no, I’ve tried replacing “here” in the code below with the enqueued .js file with no result, but I can confirm it is a defer script issue
function wpdemo_enqueue_scripts() {
wp_enqueue_script( 'HERE', get_template_directory_uri().'/js/wpdemo.js' );
}
add_action( 'wp_enqueue_scripts', 'wpdemo_enqueue_scripts' );
function add_data_jetpack_boost_tag( $src, $handle ) {
if ( $handle !== 'HERE') {
return $src;
}
return str_replace( ' src', ' data-jetpack-boost="ignore" src', $src );
}
add_filter( 'script_loader_tag', 'add_data_jetpack_boost_tag', 10, 2 );
-
This reply was modified 2 years, 4 months ago by
mikeeddie.
Hi @mikeeddie,
Sorry to hear the workaround didn’t pan out. It sounds like there’s a mismatch with the script handle or the way the exclusion is set up. Double-check the handle used in your wp_enqueue_script function matches exactly with what you’re specifying in the add_filter function.
If you’re still stuck, could you share the exact name of the script handle you’re trying to exclude? Sometimes, a fresh pair of eyes can spot something you might have missed. We’re here to help you through this!
Hello @mikeeddie,
Do you have updates about that? We usually close inactive threads after one week of no movement, but we want to make sure we’re all set before marking it as solved. Thanks!