Navigation

Tagged: 

  • Author
    Posts
  • #1326910

    nathansjcorp
    Participant

    Hi
    I would like to disable the current ajax.googleapis
    and
    fetch from one of these servers instead:

    <script src=”https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.4/jquery.min.js”></script>
    <script src=”http://code.jquery.com/jquery-2.1.4.min.js”></script>
    <script src=”http://ajax.aspnetcdn.com/ajax/jQuery/jquery-2.1.4.min.js”></script>
    <script src=”https://cdn.jsdelivr.net/jquery/2.1.4/jquery.min.js”></script>

    The reason is because the website is getting blocked in china.

    my test site:
    http://wordpress-30009-64912-195478.cloudwaysapps.com/

    Attachments:
    You must be logged in to view attached files.
    #1326957

    Rad
    Moderator

    Hi there,

    Thanks for writing in.

    Hmm, that could break your site since Google hosted jQuery doesn’t have noConflict() initialization compared to WordPress’ jQuery,

    But please try adding this code to your child theme’s functions.php

    function external_jquery() {
    	
    	if (!is_admin()) {
    
    		wp_deregister_script('jquery');
    
    		wp_register_script('jquery', '//cdn.jsdelivr.net/jquery/2.1.4/jquery.min.j', false, '2.1.4');
    		
    		wp_enqueue_script('jquery');
    
    		wp_add_inline_script( 'jquery-migrate', 'jQuery.noConflict();' );
    
    	}
    
    }
    add_action('init', 'external_jquery', -99 );

    Hope this helps.

    #1328516

    nathansjcorp
    Participant

    Hi there! thanks. Good news is that it removes the ajaxgoogleapis.
    Bad news is that it breaks the site.
    ‘Simple cornerstone slider
    column transitions
    my custom jquery
    etc…

    #1328518

    nathansjcorp
    Participant

    I have now removed the php from my functions

    #1328792

    Lely
    Moderator

    Hello There,

    From the code above, please look for this line:
    wp_register_script('jquery', '//cdn.jsdelivr.net/jquery/2.1.4/jquery.min.j', false, '2.1.4');
    Update to this:
    wp_register_script('jquery', '//cdn.jsdelivr.net/jquery/2.1.4/jquery.min.js', false, '2.1.4');
    We have a typo error on the code. URL is missing letter s at the end

    Hope this helps.

    #1329736

    nathansjcorp
    Participant

    hmm no that did not work.

    This time around it managed to register:
    cdn.jsdelivr.net/jquery/2.1.4/jquery.min.js

    but the ajax.googleapis is still there
    and it breaks the site
    Simple cornerstone slider
    column transitions
    my custom jquery
    etc…

    I have now removed the php from my functions

    #1330076

    Rad
    Moderator

    Hi there,

    Would you mind providing us with login credentials so we can take a closer look? To do this, you can make a post with the following info:

    – Link to your site
    – WordPress Admin username / password
    – FTP credentials

    Don’t forget to select Set as private reply. This ensures your information is only visible to our staff.

    Thanks!

    #1331564

    nathansjcorp
    Participant
    This reply has been marked as private.
    #1331565

    nathansjcorp
    Participant
    This reply has been marked as private.
    #1331632

    Rue Nel
    Moderator

    Hello There,

    Thanks for updating in! Using a test page, I no longer see the ajax.googleapi error or even find it in the view source of the page.
    http://prntscr.com/dw7ldu
    http://prntscr.com/dw7m4z

    This could just be a caching issue. Since you have installed a caching plugin W3 Total Cache, please clear your plugin cache before testing your site. This can cause the changes to not take place on the front end. It will eventually show up when the cache regenerates, but it’s not ideal if you’re looking to see your changes immediately. Caching plugins are best to turn on only when you’ve finished building the site.

    Please let us know how it goes.

    #1331667

    nathansjcorp
    Participant

    LOL, of course it won’t show up if you only create a blank page.

    try again now:
    http://wordpress-30009-64912-202970.cloudwaysapps.com/x-cs-test/

    #1331702

    Lely
    Moderator

    Hello There,

    I did check again and the issue is not there when I view the page in frontend. I can’t check in Cornerstone because you’re currently editing the page.

    #1331759

    nathansjcorp
    Participant

    you need to right click the inspector in chrome

    Go ahead and take over the page its yours!

    https://developers.google.com/web/tools/chrome-devtools/

    Attachments:
    You must be logged in to view attached files.
    #1332969

    Lely
    Moderator

    Hello There,

    When I check your site again, I cannot see above script on your child theme functions.php file. Did you remove it?

    #1332971

    nathansjcorp
    Participant

    I you read above you can see that i removed it.

Purchase for access

Buy a copy of X for access to our member center.

Buy