• Resolved silencerocks

    (@silencerocks)


    Hello!
    First of all – this is an excellent plugin.

    One thing that i find not so good is: it loads the dashicons – and if you dont use icons at all it’s just the Dropdown-Arrows.

    Which means 28kB loading dashicons.min.css for 1 Symbol that could be replaced by the standard like “^”.

    Is there a simple way to get rid of the dashicons request?

    A solution would be possible by combining

    
    
    // Remove dashicons in frontend for unauthenticated users
    add_action( 'wp_enqueue_scripts', 'bs_dequeue_dashicons' );
    function bs_dequeue_dashicons() {
        if ( ! is_user_logged_in() ) {
            wp_deregister_style( 'dashicons' );
        }
    }
    

    and the method, he uses to replace Dashicon set with Font Awesome in Documentation

    
    function megamenu_use_fontawesome_arrows( $vars, $location, $theme, $menu_id, $theme_id ) {
    	$vars['arrow_font'] = "'Font Awesome 5 Free'";
    	$vars['arrow_font_weight'] = "900";
    	$vars['arrow_up'] = "'\\f106'";
    	$vars['arrow_down'] = "'\\f107'";
    	$vars['arrow_left'] = "'\\f104'";
    	$vars['arrow_right'] = "'\\f105'";
    	return $vars;
    }

    add_filter( “megamenu_scss_variables”, “megamenu_use_fontawesome_arrows”, 10, 5 );

    But that is already to difficult for me.

    What do you suggest?

    Kind regards

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author megamenu

    (@megamenu)

    Hi Silence,

    Dashicons are also used for the mobile toggle (unless you replace it with a ‘Menu Toggle (Animated)’ block).

    The route you’ve suggested is the only one that would work. Do you have Font Awesome on your website already (if you have the Pro version, then the answer will be yes)? If so, the code you have pasted should work.

    Regards,
    Tom

    Thread Starter silencerocks

    (@silencerocks)

    Hello Tom,
    thank you for your quick response. I dont use font awesome on my site but i would just use a standard ascii character – doesn’t have to be pretty, just fast 🙂

    could you provide the code to replace that mobile toggle with the one the generatepress theme uses by default?

    https://generatepress.com/fastest-wordpress-theme/

    I tried myself, but this is beyond my skills.

    Nevertheless thanks for excellent support!

    • This reply was modified 4 years, 1 month ago by silencerocks.
    Plugin Author megamenu

    (@megamenu)

    Hi Silence,

    Please go to Mega Menu > Menu Themes > Custom Styling and add the following:

    #{$wrap} #{$menu} li.mega-menu-item-has-children > a.mega-menu-link > span.mega-indicator:after {
        font-family: inherit;
        content: "↓";
    }

    Then you should be able to dequeue dashicons using whichever method you find works for you.

    The mobile toggle I was referring to was the one you can find under Mega Menu > Menu Themes > Mobile Menu > Toggle Bar Designer. In there you can remove the standard ‘Menu Toggle’ block (that uses Dashicons) and replace it with a ‘Menu Toggle – Animated’ block, which is pure CSS.

    Regards,
    Tom

    Thread Starter silencerocks

    (@silencerocks)

    Excellet, Thank You!

    Plugin Author megamenu

    (@megamenu)

    You’re welcome 🙂

    Thread Starter silencerocks

    (@silencerocks)

    just a notice: The mobile menu also needs a arrow up symbol. So all in all it is:

    In Mega Menu > Themes > Individual Styling

    
    #{$wrap} #{$menu} li.mega-menu-item-has-children > a.mega-menu-link > span.mega-indicator:after {
        font-family: inherit;
        content: "▾";
    }
    
    #{$wrap} #{$menu} li.mega-menu-item-has-children.mega-toggle-on>a.mega-menu-link>span.mega-indicator:after {
        content: '▴';
    }

    and to dequeue Dashicons for non-admin

    // remove dashicons in frontend to non-admin 
        function wpdocs_dequeue_dashicon() {
            if (current_user_can( 'update_core' )) {
                return;
            }
            wp_deregister_style('dashicons');
        }
        add_action( 'wp_enqueue_scripts', 'wpdocs_dequeue_dashicon' );
Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Drop Dashicons for Performance’ is closed to new replies.