The invention discloses a dynamic
replacement method and device for a static resource URL and a
computer program product, a Proxy proxy object is created for the static resource URL through an innovative
JavaScript proxy mechanism, then a get trap in the Proxy proxy object is utilized to determine an optimal CDN resource
domain name from an alternative static resource
library after a CDN resource access request is received, and then the optimal CDN resource
domain name is replaced by the optimal CDN resource
domain name in the alternative static resource
library. On the basis of the optimal CDN resource domain name, an optimal static resource URL can be generated; and finally, replacing the original static resource URL by using the optimal static resource URL, thereby completing the dynamic replacement of the original static resource URL. By means of the design, compared with a traditional technology, manual intervention is not needed, the cost is reduced, the configuration efficiency is improved, meanwhile, dynamic selection of the optimal CDN node is achieved, the resource loading speed can be guaranteed, and then the operation performance is improved; therefore, the method is very suitable for large-scale application and popularization.