Use Google AJAX library to accelerate Wordpress

Yesterday I said, How to compress jquery.js In fact, it's just my help. There is no solution. Vango left a message saying that jquery The version of. js 1.1 was tested just now, and the foreground is OK. In fact, I don't know where the foreground needs to be used, so I haven't removed the foreground load temporarily. However, when I change to jquery When. js 1.1 was released, there was a problem in the background. The most obvious problem was the visual editing of the editor, which directly led to the blank screen of my blog yesterday afternoon

After using 1.1, there are other small problems. When adding articles in the background, tags cannot be added and article categories cannot be added. I found these problems for the time being. I think there should be other problems. I'm too lazy to test them one by one. I'd better switch back to version 1.3.2

Is that all I can do? No, since the 1.1 version can't be used, but there is Google Google Ajax library can be used directly http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js The files here have been compressed. It seems to be 19K. Compared with 56K, it's almost 40K If it is used directly, it is to change the script loader. php file under wp includes. The problem is that the editor is not visible, which is unpleasant

Okay, don't be afraid, go on Google OK. The near perfect solution appears in front of me. It is to judge whether it is the background. If it is the background, load the original jquery . js, otherwise load Google Ajax library. How to do it specifically? In fact, it's very simple. I'm the leader. I'll tell you later where the original link is

wp- includes Lower script -Loader.php, about 120 lines, contains the following code:

 $scripts->add( 'jquery', '/wp-includes/js/jquery/jquery.js', false, '1.3.2');

This is the modification. Why? Next look:

 if(strpos($_SERVER['REQUEST_URI'], '/wp-admin/') !=  false) { $scripts->add( 'jquery', '/wp-includes/js/jquery/jquery.js', false, '1.3.2'); }else{ $scripts->add( 'jquery', ' http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js ', false, '1.3.2'); }

Determine whether it is in the background. If yes, load the original js, otherwise load Gogole's. Continue testing, OK
I still found a problem. I don't know why. After switching, the editor visualization is available, but I can't switch to html mode Just change back to the original. I don't understand why

The methods in the article come from: Tuya Thank you!

Appreciation

see wordpress google jquery script includes Related articles for

Please specify that the original article of this website is reproduced from To be kicked , Link: https://www.itlu.net/articles/1302.html

Comment list (12)

  1. If it is useful for the front desk, then add a judgment
    For example, if (is_home() or is_single())

  2. The foreground doesn't know where to use it. The background knows that editors, labels, and classifications need to be used

  3. Happy New Year

  4. Is 40K that fast?

  5. @Coyote Sister
    Tongle. Hehe

    @Instant noodles
    Because I have a lot of theme pictures, try to reduce them if you can Although the current network speed has little impact, once the network speed is slow, it will have an impact

  6. Test effect

  7. @Rivers
    The effect has been blocked, please retest

  8. I haven't paid much attention to this

  9. Js acceleration foreground~good

  10. Why can't I read other people's messages. I can only see half of the head portrait. I asked the landlord about this very early. But it hasn't been solved. I'm IE8

  11. @Suzhou
    No, I just tested with IE8, and didn't find the problem you said Message problem, before Google's advertising code was slow, dragging the page, now it should be gone

  12. @sk
    Unfortunately, there will be problems when you use it, but you still have to replace it

Add a comment

Hello! #Please fill in the information# determine

Reward the blogger for drinking water
 LOADING