Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 13 additions & 8 deletions src/jquery.i18n.messagestore.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
var MessageStore = function () {
this.messages = {};
this.sources = {};
};
},
sync = false;

/**
* See https://github.com/wikimedia/jquery.i18n/wiki/Specification#wiki-Message_File_Loading
Expand Down Expand Up @@ -111,13 +112,17 @@
function jsonMessageLoader( url ) {
var deferred = $.Deferred();

$.getJSON( url )
.done( deferred.resolve )
.fail( function ( jqxhr, settings, exception ) {
$.i18n.log( 'Error in loading messages from ' + url + ' Exception: ' + exception );
// Ignore 404 exception, because we are handling fallabacks explicitly
deferred.resolve();
} );
$.ajax( {
url: url,
dataType: 'json',
async: !sync
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

synchronous loading of any resource is very bad from performanace and user experience perspective. If used with a complex application, the implications are very random and unexpected.
So, if there is a usecase that is not really supported by this library, we can discuss alternate approaches but this approach is problematic

} )
.done( deferred.resolve )
.fail( function ( jqxhr, settings, exception ) {
$.i18n.log( 'Error in loading messages from ' + url + ' Exception: ' + exception );
// Ignore 404 exception, because we are handling fallabacks explicitly
deferred.resolve();
} );

return deferred.promise();
}
Expand Down