[Support request] Have me function to remove CSS and Javascript

Home Forums Support [Support request] Have me function to remove CSS and Javascript

Home Forums Support Have me function to remove CSS and Javascript

Viewing 15 posts - 1 through 15 (of 16 total)
  • Author
    Posts
  • #1607727
    Mr Calvert

    I need remove some CSS because I was have different CSS code replace this. Can you help me function or some way to remove this CSS:
    /wp-content//plugins/gp-premium/blog/functions/css/columns.min.css (generate-blog-columns-css)
    /wp-content/themes/generatepress/assets/css/main.min.css (generate-style-css)
    /wp-content/themes/generatepress_child/style.css (generate-child-css)
    /wp-includes/css/dist/block-library/style.min.css (wp-block-library-css)
    And this:
    <style id=”generateblocks-css”>
    Please have me function to remove that CSS.

    And some Js I need remove:
    generate-navigation-search-js-extra’>
    generate-back-to-top-js
    generate-navigation-search-js
    generate-main-js-extra

    Please try help me, don’t anwser reason for why I need that, I alway received the first answer for reason, with this case I only need that for test with my theme. Please help me!!! thanks you so much!!!

    #1607860
    David
    Staff
    Customer Support
    #1608209
    Mr Calvert

    I was add code like this:
    // Remove CSS not used GeneratePress
    add_action( ‘wp_enqueue_scripts’, ‘generate_replace_inline_css’, 100 );
    function generate_replace_inline_css() {
    wp_dequeue_style( ‘generate-fonts’ );
    wp_dequeue_style( ‘generate-widget-areas’ );
    wp_dequeue_style( ‘generateblocks’ );
    wp_dequeue_style( ‘generate-style’ );
    wp_dequeue_style( ‘generatepress-dynamic’ );

    wp_dequeue_style( ‘generate-blog-css’ );
    wp_dequeue_style( ‘generate-blog-columns-css’ );
    wp_dequeue_style( ‘generate-comments-css’ );
    wp_dequeue_style( ‘generate-main’ );
    }

    But it not work with:
    wp_dequeue_style( ‘generate-blog-css’ );
    wp_dequeue_style( ‘generate-blog-columns-css’ );
    wp_dequeue_style( ‘generate-comments-css’ );
    wp_dequeue_style( ‘generate-main’ );

    Can you check and help me me detail like I need?

    #1608215
    Mr Calvert

    And I was try remove two this js but not useful
    <script id=’generate-main-js-extra’>
    <script id=’generate-navigation-search-js-extra’>

    I was use this code:
    // Remove javascript in GeneratePress
    add_action( ‘wp_enqueue_scripts’, ‘tu_remove_menu_scripts’, 50 );
    function tu_remove_menu_scripts() {
    // wp_dequeue_script( ‘generate-back-to-top’ );
    // wp_dequeue_script( ‘generate-navigation-search’ );
    wp_dequeue_script( ‘generate-blog-js-extra’ );
    // wp_dequeue_script( ‘generate-main’ );
    wp_dequeue_script( ‘generate-navigation-search-js-extra’ );
    }

    Can you give me detail?

    #1608711
    Elvin
    Staff
    Customer Support

    Hi,

    To be know what to dequeue, you can check this theme file so you get an idea of which scripts and styles are being enqueued.
    https://github.com/tomusborne/generatepress/blob/master/inc/general.php

    You can browse to this file to get a better picture of all the styles and scripts that are enqueued so you know exactly which handle to dequeue.:)

    Also, make sure to pay attention to the difference between wp_dequeue_style() and wp_dequeue_script().

    Example:
    wp_dequeue_style(generate-[style-handle]) removes wp_enqueue_style(generate-[style-handle]) and wp_dequeue_script(generate-[script-handle]) removes wp_enqueue_script(generate-[script-handle]).

    https://developer.wordpress.org/reference/functions/wp_dequeue_script/
    https://developer.wordpress.org/reference/functions/wp_dequeue_style/

    As for <script id=’generate-navigation-search-js-extra’>:
    This is automatically removed when you disable the search bar in the customizer.

    It’s added through a wp_localize_script() function within general.php when you enable the search bar.

    It is dequeued when you uncomment // wp_dequeue_script( 'generate-navigation-search' );

    As for <script id=’generate-main-js-extra’>:
    It’s pretty much the same with <script id=’generate-navigation-search-js-extra’>. It is dequeued when you dequeue generate-main.

    A wise man once said:
    "Have you cleared your cache?"

    #1608811
    Mr Calvert

    And how to remove generate-blog-js-extra sir? Can you explaind for me?

    #1608814
    Mr Calvert

    And how to remove generate-blog-js-extra sir? Can you explaind for me?
    I was try remove like your talk but I think it not effect with plugin generateblocks plugin.
    I add this code:
    wp_dequeue_style( ‘generate-blog-css’ );
    wp_dequeue_style( ‘generate-blog-columns-css’ );
    But it not effect or remove. Can you give me detail code?

    #1608818
    Elvin
    Staff
    Customer Support

    And how to remove generate-blog-js-extra sir? Can you explaind for me?

    This is only added to the site when you enable masonry and/or infinite scroll on Appearance > Customize > Layout > Blog.

    If you disable it, the particular script shouldn’t enqueue.

    You can check how it works on your GP Premium plugin file. It’s found on /plugins/gp-premium/blog/functions/generate-blog.php Line 51 to Line 92 if you check on your plugin editor.

    wp_dequeue_style( ‘generate-blog-css’ );
    wp_dequeue_style( ‘generate-blog-columns-css’ );

    This particular code removes the CSS, not the JS.

    I was try remove like your talk but I think it not effect with plugin generateblocks plugin.

    All of the enqueued scripts and styles you’ve mentioned are from GeneratePress and GP Premium. If you also want to dequeue GenerateBlock’s style and scripts you can file what’s enqueues on these files:
    https://github.com/tomusborne/generateblocks/tree/master/includes

    Note: We don’t recommend dequeuing these files as they may break the plugin’s function.

    A wise man once said:
    "Have you cleared your cache?"

    #1608825
    Mr Calvert

    How to remove with code function add child theme?
    wp_dequeue_style( ‘generate-blog-css’ );
    wp_dequeue_style( ‘generate-blog-columns-css’ );
    Or only way is deleted on Plugin sir?

    #1608861
    Elvin
    Staff
    Customer Support

    How to remove with code function add child theme?
    wp_dequeue_style( ‘generate-blog-css’ );
    wp_dequeue_style( ‘generate-blog-columns-css’ );
    Or only way is deleted on Plugin sir?

    Use wp_dequeue_style( 'generate-blog-columns' ); and wp_dequeue_style( 'generate-blog' ); instead.

    wp_dequeue_style( ‘generate-blog-columns’ ); is not enqueued when “Display posts in columns” is not checked under Appearance > Customize > Layout > Blog.

    To dequeue both, on your child theme you should have a function named generatepress_child_enqueue_scripts().

    Add this in wp_dequeue_style( 'generate-blog' ); wp_dequeue_style( 'generate-blog-columns' ); into the function to dequeue it.

    The code will look something like this.

    function generatepress_child_enqueue_scripts() {
    	if ( is_rtl() ) {
    		wp_enqueue_style( 'generatepress-rtl', trailingslashit( get_template_directory_uri() ) . 'rtl.css' );
    	}
    	wp_dequeue_style( 'generate-blog' );
        wp_dequeue_style( 'generate-blog-columns' );
    }
    add_action( 'wp_enqueue_scripts', 'generatepress_child_enqueue_scripts', 100 );

    A wise man once said:
    "Have you cleared your cache?"

    #1608901
    Mr Calvert

    All it ok. But can you have me remove this, give me function like you was sent!!!
    I need remove: <style id=”generateblocks-css”>
    I was try add this:

    function generatepress_child_enqueue_scripts() {
    	if ( is_rtl() ) {
    		wp_enqueue_style( 'generatepress-rtl', trailingslashit( get_template_directory_uri() ) . 'rtl.css' );
    	}
    	wp_dequeue_style( 'generate-blog' );
        wp_dequeue_style( 'generate-blog-columns' );
    	wp_dequeue_style( 'generateblocks' );
    }

    But it not useful!

    #1608913
    Elvin
    Staff
    Customer Support

    All it ok. But can you have me remove this, give me function like you was sent!!!
    I need remove: <style id=”generateblocks-css”>

    Ah, for that one, I’m afraid you’ll have to edit the plugin file itself to remove it.

    Here’s the line that outputs that tag.
    https://github.com/tomusborne/generateblocks/blob/5e53fe1c8c612b54972954f14a63d86199f3b1e0/includes/class-enqueue-css.php#L130

    We don’t recommend removing it as it is not useless. The plugin uses it for styling the blocks. If you remove it, you’ll most likely break how the plugin displays its blocks.

    A wise man once said:
    "Have you cleared your cache?"

    #1608945
    Mr Calvert

    Can you help me last question?

    You was guide for me this to remove javascript:

    “As for <script id=’generate-navigation-search-js-extra’>:
    This is automatically removed when you disable the search bar in the customizer.

    It’s added through a wp_localize_script() function within general.php when you enable the search bar.

    It is dequeued when you uncomment // wp_dequeue_script( ‘generate-navigation-search’ );

    As for <script id=’generate-main-js-extra’>:
    It’s pretty much the same with <script id=’generate-navigation-search-js-extra’>. It is dequeued when you dequeue generate-main.

    I was know that and when dequeued generate-main and generate-navigation-search it will lost generate-main-js-extra and generate-navigation-search-js-extra. But I need function for remove only generate-main-js-extra and generate-navigation-search-js-extra and keep generate-main and generate-navigation-search have any function to do that or only need edit in source code?

    #1608957
    Elvin
    Staff
    Customer Support

    I was know that and when dequeued generate-main and generate-navigation-search it will lost generate-main-js-extra and generate-navigation-search-js-extra. But I need function for remove only generate-main-js-extra and generate-navigation-search-js-extra and keep generate-main and generate-navigation-search have any function to do that or only need edit in source code?

    You’ll have to edit the theme and plugin files to do that.

    Reminder: We don’t recommend doing this. We don’t add in “useless” styles and/or scripts. You may end up breaking your site or some theme functionalities if you do this.

    A wise man once said:
    "Have you cleared your cache?"

    #1608963
    Mr Calvert

    Yes thanks you so much ^^! All best with you!

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