• Hello there,

    In the process to defer parsing of JavaScript to my working in progress site https://www.iamericas.org/wordpress I added the following code to theme functions.php file

    
    function defer_parsing_of_js ( $url ) {
    if ( FALSE === strpos( $url, '.js' ) ) return $url;
    if ( strpos( $url, 'jquery.js' ) ) return $url;
    return "$url' defer ";
    }
    add_filter( 'clean_url', 'defer_parsing_of_js', 11, 1 );
    

    After refreshing the page the home page wouldn’t load properly, but the rest of the site loads fine. I am also unable to access the back end (blank page). I restored the original functions.php and database from back up, but not luck.

    Any help is highly appreciated.

    • This topic was modified 6 years, 7 months ago by Jose Castaneda. Reason: added backticks for code
Viewing 5 replies - 1 through 5 (of 5 total)
  • Moderator Jose Castaneda

    (@jcastaneda)

    THEME COFFEE MONKEY

    Wait, are you trying to add defer to all of your JavaScript files?

    If so, that filter would be the wrong one. The one you want to use is the script_loader_tag one.

    The developer docs: https://developer.www.ads-software.com/reference/hooks/script_loader_tag/

    • This reply was modified 6 years, 7 months ago by Jose Castaneda. Reason: use correct filter name
    Thread Starter Carlos

    (@jcarlosf)

    Hi Jose,

    Thank you for your feed back. I followed the instructions from this site, https://support.dymond.digital/support/topic/how-to-defer-parsing-of-javascript-in-wordpress/, but the issue now is that after I restored the functions.php to the original one and I restored the DB from a previous backup I still can’t access the back end (blank page after login)

    Moderator Jose Castaneda

    (@jcastaneda)

    THEME COFFEE MONKEY

    I still can’t access the back end (blank page after login)

    Are you able to deactivate plugins via FTP?

    Thread Starter Carlos

    (@jcarlosf)

    Yes, I should be able to deactivate plugins via FTP.

    Interesting development, in order to debug the site I added the below code to the wp-config.php and then the site loads fine in the front end, but I still get a blank page in the back end.

    
    // Enable WP_DEBUG mode
    define( 'WP_DEBUG', true );
    
    // Enable Debug logging to the /wp-content/debug.log file
    define( 'WP_DEBUG_LOG', true );
    
    // Disable display of errors and warnings 
    define( 'WP_DEBUG_DISPLAY', false );
    @ini_set( 'display_errors', 0 );
    
    // Use dev versions of core JS and CSS files (only needed if you are modifying these core files)
    define( 'SCRIPT_DEBUG', true );
    
    • This reply was modified 6 years, 7 months ago by Carlos.
    • This reply was modified 6 years, 7 months ago by Carlos.
    • This reply was modified 6 years, 7 months ago by Jose Castaneda. Reason: added backticks to code
    Moderator Jose Castaneda

    (@jcastaneda)

    THEME COFFEE MONKEY

    Yeah, that helps in debugging.

    If you are able to see the error_log that can also help in finding why it doesn’t load the admin

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘WordPress not working after defer parsing javascript’ is closed to new replies.