[Resolved] How to remove Javascript?

Home Forums Support [Resolved] How to remove Javascript?

Home Forums Support How to remove Javascript?

Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #1557138
    Mr Calvert

    Can you help me function to remove javascript one by one in this list?
    generate-main-js
    navigation-search.min.js
    back-to-top.min.js
    I want to remove that to test effect. I think I not use navigation-search and back-to-top, can you give me function to remove that and CSS of its?

    #1557185
    Elvin
    Staff
    Customer Support

    Hi,

    You can try dequeuing them with this PHP snippet.

    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-main' );
    }

    However, the style for these can’t be easily removed without affecting other things in your site as most styles for your site are added in a single stylesheet.

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

    #1558861
    Mr Calvert

    Yes thanks you so much!!!

    #1558868
    Mr Calvert

    Can you help me with code css I need remove CSS of search bar and back to top buttom! I was deactive that js so I want remove css too

    #1559393
    Elvin
    Staff
    Customer Support

    Can you help me with code css I need remove CSS of search bar and back to top buttom! I was deactive that js so I want remove css too

    This is pretty tricky as the search bar and back to top button doesn’t have their own stylesheet file.

    Their default CSS styles are added within main.css while their non-default styles from Appearance > Customizer is added inline on generate-style-inline-css with again, is combined w/ every other styles.

    That said, we can’t just dequeue generate-main and generate-style-inline as it will also affect other parts of the site.

    However, you can just override them w/ your child theme or custom CSS added on Additional CSS.

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

    #1559436
    Mr Calvert

    And the last question. I was check in blog and category I see it have new js file auto call is list:
    jquery.js
    infinite-scroll.pkgd.min.js
    scripts.min.js
    And this javascript I see it call in header: script id=’generate-blog-js-extra’
    And
    script id=’generate-classlist-js’
    Have any function or turn off that? I want turn off that for testing! Can you help me that function?

    #1559471
    Elvin
    Staff
    Customer Support

    You can remove jquery by dequeuing it, wp_dequeue_script( 'jquery' );.

    I don’t recommend doing this though. Some plugins may be using this library as well.

    generate-classlist-js I believe this one is turned off by default. Its only for IE 11 browsers. You can check it on the page source as !– commented out meaning it doesn’t run.

    infinite-scroll.pkgd.min.js is only added when you enable infinite scroll on the customizer. You can turn it off it the same way you enabled it on the customizer if you want it removed. generate-blog-js-extra works w/ infinite scroll script and is also removed if you disable infinite scroll.

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

    #1559479
    Mr Calvert

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

    #1559666
    Elvin
    Staff
    Customer Support

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

    No problem. Glad to be of any help.:)

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

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