Home Forums Basel support forum Visual Composer files loaded on every page

Visual Composer files loaded on every page

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #13060

    altitudes89
    Participant

    Hello

    Basel theme loads Visual Composer files on every page (this is done in Basel functions.php), and it makes the pages (unnecessarily?) heavy.

    Is there any good reason for that? Usually these files are loaded only on pages built with Visual Composer, so on very few pages on an ecommerce site 😉

    Thanks

    #13065

    Artem Temos
    Keymaster

    Hi,

    Actually, it doesn’t make the theme too heavy. You can use some optimization plugin that will combine all CSS files into one. Anyway, you can disable it by adding the following code snippet to the functions.php file in the child theme

    
    	add_action( 'wp_enqueue_scripts', 'basel_enqueue_styles', 10000 );
    
    	function basel_enqueue_styles() {
    
    		if( basel_get_opt( 'minified_css' ) ) {
    			$main_css_url = get_template_directory_uri() . '/style.min.css';
    		} else {
    			$main_css_url = get_stylesheet_uri();
    		}
    
    		wp_dequeue_style( 'yith-wcwl-font-awesome' );
    		wp_dequeue_style( 'vc_pageable_owl-carousel-css' );
    		wp_dequeue_style( 'vc_pageable_owl-carousel-css-theme' );
    		wp_enqueue_style( 'font-awesome-css', BASEL_STYLES . '/font-awesome.min.css', array() );
    		wp_enqueue_style( 'bootstrap', BASEL_STYLES . '/bootstrap.min.css', array() );
    		wp_enqueue_style( 'basel-style', $main_css_url, array( 'bootstrap' ) );
    
    		if( apply_filters( 'basel_dynamic_css' , true ) ) {
    			wp_enqueue_style( 'dynamic-styles', BASEL_THEME_DIR . '/inc/dynamic-styles.php', array() );
    		}
    
    		remove_action('wp_head', 'print_emoji_detection_script', 7);
    		remove_action('wp_print_styles', 'print_emoji_styles');
    	}
    

    Regards

    #13069

    altitudes89
    Participant

    Thank you. I did the following instead:

    add_action( 'wp_enqueue_scripts', create_function( '', 'wp_dequeue_style( \'js_composer_front\' );' ), 10001 );

    This does not tell me why Basel needs Visual Composer CSS…

    Note that because pages ressources are not gzipped on my hosting, this really makes a difference 😉

    #13072

    Artem Temos
    Keymaster

    If you are not going to use Visual Composer then you don’t need to keep this file.

    Regards

Viewing 4 posts - 1 through 4 (of 4 total)