From 95bf856810a8ecdc6829c765d522549562e5803c Mon Sep 17 00:00:00 2001 From: Steve Wasiura Date: Wed, 10 Sep 2014 14:52:26 -0400 Subject: [PATCH] findScriptPathAndLoadModules speed up path speed up path detection instead of looping through each script in DOM and checking src to see if it is form-validator, change jQ selector to use AttributeContains modifier so the correct script is detected the first loop --- form-validator/jquery.form-validator.js | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/form-validator/jquery.form-validator.js b/form-validator/jquery.form-validator.js index aab285e..aab0a13 100644 --- a/form-validator/jquery.form-validator.js +++ b/form-validator/jquery.form-validator.js @@ -762,16 +762,11 @@ } else { var findScriptPathAndLoadModules = function() { var foundPath = false; - $('script').each(function() { - if( this.src ) { - var scriptName = this.src.substr(this.src.lastIndexOf('/')+1, this.src.length); - if(scriptName.indexOf('jquery.form-validator.js') > -1 || scriptName.indexOf('jquery.form-validator.min.js') > -1) { - foundPath = this.src.substr(0, this.src.lastIndexOf('/')) + '/'; - if( foundPath == '/' ) - foundPath = ''; - return false; - } - } + $('script[src*="form-validator"]').each(function() { + foundPath = this.src.substr(0, this.src.lastIndexOf('/')) + '/'; + if( foundPath == '/' ) + foundPath = ''; + return false; }); if( foundPath !== false) {