Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #695753

    isn’t it a good idea to load instead from wp-includes/js folder the google hosted libraries ?
    Or do you think its nonsense.
    If an installation is online this might be a good alternative on performance aspects.?

    #696870

    Hey Guenter!

    Thank you for using Enfold.

    I think this will answer that question.

    6. Addendum: Theme Repositories Do Not Permit Replacing jQuery

    Many theme repositories, including the official WordPress.org repository and ThemeForest.net, do not permit themes to replace the default version of jQuery. If you wish to have your theme listed in one of the large, popular repositories, do yourself a favor and don’t even try.

    // https://pippinsplugins.com/why-loading-your-own-jquery-is-irresponsible/

    Cheers!
    Ismael

    #696919

    thanks – ok

    #696961

    Hi,

    If you still like to go ahead and load your own for custom jQuery for customization purpose Please try adding this at the very end of your themes / child themes functions.php file:

    /* Force load jQuery First */
    if (!is_admin()) add_action("wp_enqueue_scripts", "my_jquery_enqueue", 11);
    function my_jquery_enqueue() {
       wp_deregister_script('jquery');
       wp_register_script('jquery', "http" . ($_SERVER['SERVER_PORT'] == 443 ? "s" : "") . "://ajax.googleapis.com/ajax/libs/jquery/1/jquery.js", false, null);
       wp_enqueue_script('jquery');
    }

    Best regards,
    Vinay

    #778242

    in the meanwhile a lot of other big players do offer such things. for example: CDN itself : https://cdnjs.com/

    if ;) i would now take that code here:

    if( !is_admin()){ 
        $url = 'https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js'; 
        $test_url = @fopen($url,'r'); 
        if($test_url !== false) { 
            function load_external_jQuery() {
                wp_deregister_script('jquery'); 
                wp_register_script('jquery', 'https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js'); 
                wp_enqueue_script('jquery'); 
            }
            add_action('wp_enqueue_scripts', 'load_external_jQuery'); 
        } else {
            function load_local_jQuery() {
                wp_deregister_script('jquery'); 
                wp_register_script('jquery', '/wp-includes/js/jquery/jquery.js', __FILE__, false, '1.12.4', true); 
                wp_enqueue_script('jquery'); 
            }
        add_action('wp_enqueue_scripts', 'load_local_jQuery'); 
        }
    }
    #778448

    Hi,

    Thank you for sharing this solution @Guenni007

    Best regards,
    Vinay

    #779325

    hm but it seems to be not the way – and performace advantages are less than supposed to be.

    the wordpress embedded jquery runs in “no conflict” mode – so if you like to rund from a cdn it must be under the same conditions.
    How i could obtain that – will be my next study

    #779335

    Hi!


    @Guenni007
    also keep in mind that if you are loading the latest version, some times there might be issues that effect the theme also
    I do not know if you remember, almost a year ago an issue with the latest Jquery version that WordPress pushed through and it ” crashed ” 10% of the web, because there was conflicts.

    In any case, you do know to solve most of the issues your self, so I think you will not have a problem :D

    Cheers!
    Basilis

    #779974

    yes i know – so thats why the code above is with same version as WordPress used now.
    And if its not on the cdn the embedded is loaded. (f.e. if your offline)
    And maybe if it was an exotic js file this will be an accelleration effort but with wordpress jquerry the amount of millions of installations will garantee that on personal machine there is in the cache the same js file.

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