From 871a790f3f519e1fc273ce45ae510adcb598bc5d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Junod?= Date: Thu, 7 Jan 2010 07:22:05 +0000 Subject: [PATCH] cache the result of the OpenLayers._getScriptLocation function. r=ahocevar (closes #2389) git-svn-id: http://svn.openlayers.org/trunk/openlayers@9935 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf --- lib/OpenLayers.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/OpenLayers.js b/lib/OpenLayers.js index a27cdadfef..5cbefbb5ed 100644 --- a/lib/OpenLayers.js +++ b/lib/OpenLayers.js @@ -17,6 +17,12 @@ */ var singleFile = (typeof OpenLayers == "object" && OpenLayers.singleFile); + /** + * Cache for the script location returned from + * OpenLayers._getScriptLocation + */ + var scriptLocation; + /** * Namespace: OpenLayers * The OpenLayers object provides a namespace for all things OpenLayers @@ -37,7 +43,10 @@ * {String} Path to this script */ _getScriptLocation: function () { - var scriptLocation = ""; + if(scriptLocation) { + return scriptLocation; + } + scriptLocation = ""; var isOL = new RegExp("(^|(.*?\\/))(" + OpenLayers._scriptName + ")(\\?|$)"); var scripts = document.getElementsByTagName('script');