-
AuthorPosts
-
October 5, 2016 at 8:26 pm #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.?October 8, 2016 at 9:46 am #696870Hey 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!
IsmaelOctober 8, 2016 at 6:21 pm #696919thanks – ok
October 9, 2016 at 3:39 am #696961Hi,
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,
VinayApril 15, 2017 at 5:28 pm #778242in 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'); } }
April 16, 2017 at 4:47 pm #778448April 18, 2017 at 2:50 pm #779325hm 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 studyApril 18, 2017 at 3:02 pm #779335Hi!
@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!
BasilisApril 19, 2017 at 2:25 pm #779974yes 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. -
AuthorPosts
- You must be logged in to reply to this topic.