Skip to content

Commit 95bf856

Browse files
committed
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
1 parent 0cd6b32 commit 95bf856

File tree

1 file changed

+5
-10
lines changed

1 file changed

+5
-10
lines changed

form-validator/jquery.form-validator.js

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -762,16 +762,11 @@
762762
} else {
763763
var findScriptPathAndLoadModules = function() {
764764
var foundPath = false;
765-
$('script').each(function() {
766-
if( this.src ) {
767-
var scriptName = this.src.substr(this.src.lastIndexOf('/')+1, this.src.length);
768-
if(scriptName.indexOf('jquery.form-validator.js') > -1 || scriptName.indexOf('jquery.form-validator.min.js') > -1) {
769-
foundPath = this.src.substr(0, this.src.lastIndexOf('/')) + '/';
770-
if( foundPath == '/' )
771-
foundPath = '';
772-
return false;
773-
}
774-
}
765+
$('script[src*="form-validator"]').each(function() {
766+
foundPath = this.src.substr(0, this.src.lastIndexOf('/')) + '/';
767+
if( foundPath == '/' )
768+
foundPath = '';
769+
return false;
775770
});
776771

777772
if( foundPath !== false) {

0 commit comments

Comments
 (0)