Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #1369636

    on using the new feature “Use minified theme javascript files without merging” and css pendent too –
    what we have to think of if we do load own edited scripts f.e. the avia-snippet-sticky-header.js

    do we have to deregister the minified script instead before loading the child-theme script – or will there be a conflict internally if I only use this one?

    
    function wp_change_sticky_header_script() {
       wp_deregister_script( 'avia-sticky-header' );
       wp_enqueue_script( 'avia-sticky-header-child', get_stylesheet_directory_uri().'/js/avia-snippet-sticky-header.js', array('avia-default'), $vn, true);
    }
    add_action( 'wp_enqueue_scripts', 'wp_change_sticky_header_script', 100 );
    

    or does conditon with $min_js do that job for me?

    #1369639

    Next : this here is a usefull compression tool – and i have never had conflicts with it in using it with enfold.
    if i create edited file and compress myself – regarding the enfold nomenklatur ( avia-snippet-sticky-header.min.js ) – how do i have to enque that custom js file with condition ?
    ( Uploading both files then to child-theme )

    #1369787

    Hi,

    If you want to use a custom js/css file instead of theme files you have to deregister/dequeue theme files as you show above.

    avia_minify_extension() returns ‘.min’ or ” depending on theme setting.

    If you need it in your child theme depends if you upload both versions (non minified and minified) or only one version.

    To see an example how to enqueue files have a look at e.g.

    config-templatebuilder\avia-shortcodes\icongrid\icongrid.php function extra_assets():

    
    			$ver = Avia_Builder()->get_theme_version();
    			$min_js = avia_minify_extension( 'js' );
    			$min_css = avia_minify_extension( 'css' );
    
    			wp_enqueue_style( 'avia-module-icon', AviaBuilder::$path['pluginUrlRoot'] . "avia-shortcodes/icon/icon{$min_css}.css", array( 'avia-layout' ), $ver );
    			wp_enqueue_style( 'avia-module-icongrid', AviaBuilder::$path['pluginUrlRoot'] . "avia-shortcodes/icongrid/icongrid{$min_css}.css", array( 'avia-layout' ), $ver );
    
    			wp_enqueue_script( 'avia-module-icongrid', AviaBuilder::$path['pluginUrlRoot'] . "avia-shortcodes/icongrid/icongrid{$min_js}.js", array( 'avia-shortcodes' ), $ver, true );
    

    Best regards,
    Günter

    #1369838

    yes this is clear – but in the case above we have on functions.php the case of having conditions.
    deregister will be as it was before – but register the child-theme file ?

    avia_enqueue_script_conditionally( $condition2 , 'avia-sticky-header', "{$template_url}/js/avia-snippet-sticky-header{$min_js}.js", array( 'avia-default' ), $vn, true );
    

    how to have here a child-theme pendent – if we want to offer both ( minified file and standard file) ?

    #1369858

    Hi,

    You can use the same steps as in avia_register_frontend_scripts() in functions.php:

    
    		$min_js = avia_minify_extension( 'js' );
    		$min_css = avia_minify_extension( 'css' );
    
    		$condition2 = .....
    
    		avia_enqueue_script_conditionally( $condition2 ,'avia-sticky-header', "{$template_url}/js/avia-snippet-sticky-header{$min_js}.js", array( 'avia-default' ), $vn, true );
    

    And you have to upload both files.

    Do I missunderstand something?

    Best regards,
    Günter

    #1369959

    ok – everything that is mentioned in functions.php had to be there for registering the child-theme:

    function wp_change_sticky_header_script() {
    	wp_deregister_script( 'avia-sticky-header' );
    
    	$vn = avia_get_theme_version();
    	$options = avia_get_option();
    	$child_theme_url = get_stylesheet_directory_uri();
    
    	$min_js = avia_minify_extension( 'js' );
    	//  $min_css = avia_minify_extension( 'css' );  for that js - file not needed to mention here
    
    	$condition  = ( isset( $options['header_position'] ) && $options['header_position'] == 'header_top' );
    	$condition2 = ( isset( $options['header_sticky'] ) && $options['header_sticky'] == 'header_sticky' ) && $condition;
    	avia_enqueue_script_conditionally( $condition2 , 'avia-sticky-header-child', "{$child_theme_url}/js/avia-snippet-sticky-header{$min_js}.js", array('avia-default'), $vn, true);
    }
    add_action( 'wp_enqueue_scripts', 'wp_change_sticky_header_script', 100 );

    because in condition2 – condition1 is mentioned etc. vn etc.

    #1369966

    by the way: it seems that the merging of css files in combination with minified js files have best Performance Values on my end here.

    a friend told me to deactivate better the borlabs cookie to not influence the results :

Viewing 7 posts - 1 through 7 (of 7 total)
  • You must be logged in to reply to this topic.