- This topic has 15 replies, 3 voices, and was last updated 3 years, 3 months ago by Elvin.
-
AuthorPosts
-
January 6, 2021 at 3:29 am #1607727Mr 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-extraPlease 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!!!
January 6, 2021 at 6:01 am #1607860DavidStaffCustomer SupportHi there,
Tom provides a method here:
https://generatepress.com/forums/topic/remove-generatepress-all-css-and-js/#post-1605411
January 6, 2021 at 8:17 am #1608209Mr CalvertI 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?
January 6, 2021 at 8:21 am #1608215Mr CalvertAnd 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?
January 6, 2021 at 5:10 pm #1608711ElvinStaffCustomer SupportHi,
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.phpYou 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()
andwp_dequeue_script()
.Example:
wp_dequeue_style(generate-[style-handle])
removeswp_enqueue_style(generate-[style-handle])
andwp_dequeue_script(generate-[script-handle])
removeswp_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 withingeneral.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 dequeuegenerate-main
.January 6, 2021 at 7:45 pm #1608811Mr CalvertAnd how to remove generate-blog-js-extra sir? Can you explaind for me?
January 6, 2021 at 7:53 pm #1608814Mr CalvertAnd 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?January 6, 2021 at 8:15 pm #1608818ElvinStaffCustomer SupportAnd 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/includesNote: We don’t recommend dequeuing these files as they may break the plugin’s function.
January 6, 2021 at 8:23 pm #1608825Mr CalvertHow 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?January 6, 2021 at 9:20 pm #1608861ElvinStaffCustomer SupportHow 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' );
andwp_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 );
January 6, 2021 at 10:47 pm #1608901Mr CalvertAll 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!
January 6, 2021 at 11:10 pm #1608913ElvinStaffCustomer SupportAll 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#L130We 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.
January 6, 2021 at 11:55 pm #1608945Mr CalvertCan 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
andgenerate-navigation-search
it will lostgenerate-main-js-extra
andgenerate-navigation-search-js-extra
. But I need function for remove onlygenerate-main-js-extra
andgenerate-navigation-search-js-extra
and keepgenerate-main
andgenerate-navigation-search
have any function to do that or only need edit in source code?January 7, 2021 at 12:13 am #1608957ElvinStaffCustomer SupportI 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.
January 7, 2021 at 12:16 am #1608963Mr CalvertYes thanks you so much ^^! All best with you!
-
AuthorPosts
- You must be logged in to reply to this topic.