• Resolved unicco

    (@unicco)


    Ello,

    Is it possible to disable qTranslate-X on specific areas (classes etc.) or pages, to avoid unnecessary runthrough? I’ve currently speedoptimizating my site, and qTranslate adds additionally 0.8 sec in average Waiting (TTFB). This is tested on WooCommerce-pages.

    The shop is only available in my native language, and therefore, there are no reasons for using qTranslate on these pages. Where should I apply this check in the plugin (code), to avoid it?

    Regards
    Jimmi N.

    https://www.ads-software.com/plugins/qtranslate-x/

Viewing 5 replies - 1 through 5 (of 5 total)
  • HU ist Sebastian

    (@kuchenundkakao)

    Well, you can prevent the loading of the plugin in general for specific pages, but only by URL. This seems to work like this:
    Put this in your functions.php (change the “store” to whatever page your store hierarchy is found):

    PLEASE BE SURE THAT YOUR SITE USES NO CODE RELYING ON QTRANSLATE-X ON THESE PAGES! (Or else you get fatal errors)

    add_filter( 'option_active_plugins', 'lg_disable_qtranslate_plugin' );
    
     function lg_disable_qtranslate_plugin($plugins){
          $subaddress = 'store'; //Insert here the slug to your first-level-store-subfolder
          if(strpos($_SERVER['REQUEST_URI'], '/'.$subaddress.'/')) {
             $key = array_search( 'qtranslate-x/qtranslate.php' , $plugins );
             if ( false !== $key ) unset( $plugins[$key] );
          }
    
     return $plugins;
     }

    Didn’t test it, but it should work…

    Happy Coding,
    Kuchenundkakao

    Plugin Author John Clause

    (@johnclause)

    Testing is the largest part of development ?? Testing is what is appreciated the most …

    Yes, we have inherited performance imperfections.

    An option like this is would be good indeed, if somebody could pull that in on GitHub.

    HU ist Sebastian

    (@kuchenundkakao)

    I for my part would not recommend to put this code into the plugin, as it is very “dirty”.

    I don’t think that you can build in an option into the plugin to “not load” qtranslate-x on pages or posts by page-id for instance, because many things happen on qtranslate-x’s side before we can even check which page is called for. So we can not check if we have to load qtranslate-x “if is_page(12)” because “is_page(12)” doesn’t work at the action plugins_init.

    I hope what i’m saying makes sense to you ??

    Happy coding,
    Kuchenundkakao

    dmdecalonne

    (@dmdecalonne)

    This does not work for me.
    I’ve put the code in my template’s functions.php and changed ‘store’ to ‘TNG’.
    If you change language to English on my website (https://www.decalonne.nl), and then open “Genealogy | Family Tree”, you can see the plugin still works. I’m not an expert, but at least, I think it does, because the ‘lang=en’ suffix is visible in the URL.

    Thread Starter unicco

    (@unicco)

    Thanks for the replies. I’ve been running some tests on your code, and it seems to work perfectly. It gave around 0.2 seconds improvements in TTFB, which is a slightly – nevertheless – a step in the right direction. Multiple plugins really have an negative impact on the sites performance; WooCommerce for instance, has serious performance issues regarding products with multiple attributes.

    There should be set more focus on the performance, rather than expanding the functionalities – I believe this concern WP-core aswell as plugins. An example is WooCoomerce, who has an active issue-thread, but no updates for 4 months. It’s so de-emphasized, which indeed entails to lot of frustrations for webshop-owners.

    https://github.com/woothemes/woocommerce/issues/6995

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Disable qTranslate on specific pages or classes (Speed Optimizations)’ is closed to new replies.