[Support request] Function wp_dequeue_style was called incorrectly

Home Forums Support [Support request] Function wp_dequeue_style was called incorrectly

Home Forums Support Function wp_dequeue_style was called incorrectly

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #2289962
    Techibytes Media

    So was trying to remove Google fonts with a generatePress child theme but encountered an error

    Notice: Function wp_dequeue_style was called incorrectly. Scripts and styles should not be registered or enqueued until the wp_enqueue_scripts, admin_enqueue_scripts, or login_enqueue_scripts hooks. This notice was triggered by the font-awesome handle. Please see Debugging in WordPress for more information. (This message was added in version 3.3.0.) in /home/780543.cloudwaysapps.com/bxryqrrekh/public_html/wp-includes/functions.php on line 5831`

    I had to uninstall it but if there is a way you could help me resolve this and possibly remove the Google fonts api from the function.php for me that would be appreciated too

    #2290042
    Ying
    Staff
    Customer Support

    Hi there,

    I don’t think you need to use any function to remove Google fonts, if you are not using Google fonts on your site, then it won’t load.

    Just make sure you are using the dynamic typography system:
    https://docs.generatepress.com/article/dynamic-typography-overview/

    If you are still using the old typography system, you can switch it to the dynamic system at customizer > general. https://docs.generatepress.com/article/switching-to-dynamic-typography/

    #2290066
    Techibytes Media

    I guess if i block the Google font from the typography section it will do the work? Because i just want to use Arial and not load anything that will bring up cases

    using Google fonts API, this technology impacts LCP because it loads in lots of fonts in the form of CSS files that load in before the LCP element, these are render-blocking resources and will increase LCP loading times so we advise that you remove this technology

    #2290100
    Fernando
    Customer Support

    Hello there,

    If you don’t choose any Google Font for any text in your site, through Typography or if you’re using GenerateBlocks, in the Block settings as well, Google fonts wont be loaded/enqueued. Basically, make sure that Google fonts is toggled off or not chosen anywhere.

    If you want to try to dequeue it manually, here’s a code you may try:

    add_action( 'wp_enqueue_scripts', function() {
        wp_dequeue_style( 'generate-google-fonts' );
    },99 );

    Hope this clarifies!

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