-
AuthorPosts
-
October 20, 2022 at 5:45 pm #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.jsdo 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?October 20, 2022 at 5:58 pm #1369639Next : 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 )October 22, 2022 at 11:57 am #1369787Hi,
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ünterOctober 23, 2022 at 3:06 am #1369838yes 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) ?
October 23, 2022 at 2:36 pm #1369858Hi,
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ünterOctober 24, 2022 at 12:36 pm #1369959ok – 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.
October 24, 2022 at 1:13 pm #1369966 -
AuthorPosts
- You must be logged in to reply to this topic.