*

jcarrolo01

  • *****
  • 256 posts
Small help...
« on: May 18, 2020, 01:26:20 PM »
I'm trying to defer javascript on zara theme

For that i add this code into theme function.php

Code: [Select]
function minify_js_files( $url ) {
    if ( is_user_logged_in() ) return $url; //don't break WP Admin
    if ( FALSE === strpos( $url, '.js' ) ) return $url;
    if ( strpos( $url, 'min.js' ) ) return $url;
    return str_replace( ' src', ' defer src', $url );
}
osc_add_hook( 'minify-js', 'minify_js_files', 1 );

after i run hook minify-js in footer

But seems it's not working....




The question is, how can i defer parsing of javascripp in zara theme???? There is any suggestion abou t how can defer javascript?????



Best Regards
João

*

MB Themes

Re: Small help...
« Reply #1 on: May 18, 2020, 03:06:00 PM »
@jcarrolo01
Best, simplest and fastest way is to simply merge files used in theme into one file (in order they are showing in theme) and use this file only.
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots