One of the recommendations from web performance optimization services is to minimize DNS look ups.

I fully understand why they recommend this but why not just point references to external files to the IP address?

For example:

<script src="//555.555.55.55/cdn/jquery.min.js"></script>

I have never seen this done, and my searches here came up empty, why not?


Just to clarify the question to prevent confusion: It's advised by Google to reduce the number of lookups for unique hostnames - see: Minimize DNS lookups

As indicated there, hostnames are cached in the client's browser and OS. Using an IP address instead of a hostname for files hosted on the same host would therefore not be of benefit.

For files hosted elsewhere, you shouldn't use an IP address because they can change, whereas hostnames will not. For files hosted on a CDN like jQuery, a range of IP addresses will most certainly be used for redundancy, load balancing, etc... Reaching a busy server or incorrect IP address would result in any code running the library to no longer function.

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.