Are you tiered of seeing the message waiting for “ajax.googleapis.com” at the lower bottom of your browser window and endlessly waiting for the page to load? Well, it is simple to understand that the page you are opening is trying to call something from Google servers and get struck up till the time it receives response. Here is the explanation what the page is calling from Google and possible solutions to overcome the issue.
What is ajax.googleapis.com?
Google maintain these files with the latest version and sets cache header for these libraries. This eliminates the need of placing the script libraries on individual web servers and a mere link to Google server will solve the purpose.
When a page you are trying to open has a link to call Google servers for getting the script libraries then you will see the message waiting for “ajax.googleapis.com”. Right click and view the source of the page once it is loaded, you will be seeing something like below:
<script src="//ajax.googleapis.com/ajax/libs/………."> </script>
Why Google Library Files are Used?
As mentioned above, Google host these libraries and maintain with the latest version. Assume, you are developing a WordPress plugin using JQuery libraries. Providing JQuery library files along with the plugin makes the life more difficult both for you as a developer as well as for the user. Some of the possible problems that could evolve are:
- Theme used by individual people may have different version of JQuery
- Another plugin installed may conflict with the version you have provided with your plugin
- Whenever there is an update, you need to update the plugin with the complete libraries.
- Your plugin size will be large with lot of additional library files.
To overcome all these issues, you can simply include a script line calling JQuery version library from Google servers. Since these files are up to date and most commonly used by theme and plugin developers, the possibility of version conflicts is also highly reduced.
What are the Google Libraries Offered?
Google offers the following libraries hosted on their own servers and hence including any of these scripts will call “ajax.googleapis.com” site for downloading the libraries.
Why Does It Take So Long for Loading?
Now that you must have got an idea of why the message “ajx.googleapis.com” is appearing. Let us come to the problem of why it takes so long and struck up with “waiting for ajx.googleapis.com”? When the page having a link to Google libraries is loaded, the browser will call Google servers to download all the required libraries. The problem here is the behavior of the browsers, which will render the content only after all the required script files are loaded.
This essentially means even if the external Google script libraries are not required to be executed when loading the page, browsers will display the content only after downloading the libraries. You will see “waiting for ajax.googleapis.com” message till the time the files are downloaded to your local browser. Almost all web browsers like Chrome, Firefox, Safari, Edge and IE behaves in the same manner, hence the delay can’t be avoided with the browser change.
Since Google uses caching at various levels to speed up the downloading process, it should be equivalently faster to retrieve the files from your own server. But again the caching can be affected due to many reasons resulting longer downloading time or timeout.
- Your ISP does not have proper DNS lookup setup to retrieve the data faster.
- Google services are blocked by your ISP or in your country.
1. Using Public DNS
Correct DNS setup allows the browser to get the required library files quickly from the server. By default browsers obtain DNS servers dynamically from your Internet Service Provider (ISP) which may not be efficient in getting the script files. Alternatively you can use Google public DNS which will have the cached library files and send them quickly to your browser. This will also improve the overall loading speed of the page.
2. Blocking Scripts with Hosts File
If the problem is not resolved with DNS settings change then you can block the API call to Google server by pointing it to localhost in hosts file of your PC or Mac. Browser uses hosts file to map the IP address of any site before going to DNS. Hence blocking it in the hosts file will terminate the API call and load the page without the required resources. Create the below entries in hosts file for IPv4 and IPv6 respectively:
3. Using Script Blocker
Install any browser plugins or extensions to block scripts running on the page. Again this will also stop loading the features on the page that using scripts.
4. Blocked Google Services
There are many countries block Google services. If you are living in such a country then use reliable VPN or proxy to access the page calling ajax.googleapis.com. There are premium VPN services like VpyrVPN and ExpressVPN offers anonymous browsing with private DNS. It is also possible that only your ISP blocks Google services or have issues in resolving Google server IPs causing delay in page loading. You can find out this by testing the page on a different network offered by other ISP (for example, open the page on a mobile network).
5. Flush DNS
Your computer also caches the DNS records and uses to speedup the domain resolution process. The outdated DNS records may affect the scripts loading on a page. So flush the DNS on your computer and see whether you can open the webpages without ajax.googleapis.com message.
6. Clear Browser Cache
Over the period of time, the browser may starts accumulating lot of unnecessary cookies and temporary files. These files may cause issue in loading the pages, especially when there are change in the IP / DNS / nameservers of the sites you are opening. The easiest way to overcome corrupted cookies and history files is to delete the browsing history. Generally you can delete the history and cookies by going to the settings page of your browser.
7. Contact Your ISP
If you are not able to resolve the ajax.googleapis.com loading issue with any of the above solutions then the last option is to contact your ISP. Sometimes there could be a configuration problem at ISP side which may also cause issues in loading scripts from Google servers. So your ISP can check both at their end and at your end and help you to resolve the problem.
8. For Site Owners
If you are the site owner, try to avoid using theme or plugins calling Google script libraries. There are many elements on a page like search box, sliders, related post widgets, etc. will call ajax.googleapis.com for the required script files and cause delay. Though it is a difficult task to control the use of each element, using appropriate caching mechanism to serve the files will ensure faster loading of the resources on the page.