0

I have built a plug in and it appears to hook in ok. It runs at least. However it loads very slowly. I have attached my console log results. It appears as though the base url is not correctly built in some cases. www.mydomain.com/wordpress/plugin is combining with /wp-includes/js/jquery/. These entries should be www.mydomain.com/wordpress/wp-includes/js/jquery/. I am also seeing that this is inconsistent, sometimes it is built just fine. So I am trying to track down the file where this is happening but I am a little lost. Any tips would help.

GET https://www.example.com/wordpress/plugin/wp-includes/js/jquery/jquery.js?ver=1.12.4 (index):54
GET https://www.example.com/wordpress/plugin/wp-includes/js/jquery/jquery-migrate.min.js?ver=1.4.1 404 (Not Found)  (index):55
GET https://www.example.com/wordpress/plugin/wp-includes/js/jquery/ui/core.min.js?ver=1.11.4    (index):603 
GET https://www.example.com/wordpress/plugin/wp-includes/js/jquery/ui/datepicker.min.js?ver=1.11.4 404 (Not Found)  (index):604
GET https://www.example.com/wordpress/plugin/wp-includes/js/jquery/ui/widget.min.js?ver=1.11.4  (index):606
GET https://www.example.com/wordpress/plugin/wp-includes/js/jquery/ui/slider.min.js?ver=1.11.4  (index):608
GET https://www.example.com/wordpress/plugin/wp-includes/js/jquery/ui/mouse.min.js?ver=1.11.4   (index):607
GET https://www.example.com/wordpress/plugin/wp-includes/js/jquery/ui/button.min.js?ver=1.11.4  (index):609
GET https://www.example.com/wordpress/plugin/wp-includes/js/wp-embed.min.js?ver=4.5.3   (index):616
GET https://www.example.com/wordpress/pluginjs/wp-emoji-release.min.js?ver=4.5.3    (index):28
GET https://www.example.com/wordpress/plugin/wp-includes/js/jquery/ui/slider.min.js?ver=1.11.4  (index):608 
GET https://www.example.com/wordpress/plugin/wp-includes/js/jquery/ui/button.min.js?ver=1.11.4 404 (Not Found)  (index):609
GET https://www.example.com/wordpress/plugin/wp-includes/js/wp-embed.min.js?ver=4.5.3 404 (Not Found)   (index):616
Uncaught TypeError: jQuery(...).tinyNav is not a function(…)    TinyNav.js?ver=4.5.3:91
Google sync successful  frontend_book.js:513
0

Most of the problem was resolved by pasting the following into my functions.php

     function my_init()   
{  
    if (!is_admin())   
    {  
        wp_deregister_script('jquery');  

        // Load the copy of jQuery that comes with WordPress  
        // The last parameter set to TRUE states that it should be loaded  
        // in the footer.  
        wp_register_script('jquery', '/wp-includes/js/jquery/jquery.js', FALSE, '1.11.4', TRUE);  

        wp_enqueue_script('jquery');  
    }  
}  
add_action('init', 'my_init'); 
0

How do you enqueue/register these files ? Do you try to enqueue them like your file or treat them as dépendances ?

To use any file from the WordPress core registered-scripts library, you only need to register them and set dependancies your plugin require with wp_register_script (trigger with wp_enqueue_scripts action).

You will find the list of all core-registered scripts here

Scripts that have been pre-registered using wp_register_script() do not need to be manually enqueued using wp_enqueue_script() if they are listed as a dependency of another script that is enqueued. WordPress will automatically include the registered script before it includes the enqueued script that lists the registered script’s handle as a dependency.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.