Skip to content

Commit

Permalink
Merge branch 'wip-MDL-34404-m24' of git://github.com/samhemelryk/moodle
Browse files Browse the repository at this point in the history
  • Loading branch information
danpoltawski committed Jul 23, 2012
2 parents 89061ad + dd51b3b commit db68bd4
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lib/javascript-static.js
Expand Up @@ -716,7 +716,13 @@ M.util.get_string = function(identifier, component, a) {
// creating new instance if YUI is not optimal but it seems to be better way then
// require the instance via the function API - note that it is used in rare cases
// for debugging only anyway
var Y = new YUI({ debug : true });
// To ensure we don't kill browser performance if hundreds of get_string requests
// are made we cache the instance we generate within the M.util namespace.
// We don't publicly define the variable so that it doesn't get abused.
if (typeof M.util.get_string_yui_instance === 'undefined') {
M.util.get_string_yui_instance = new YUI({ debug : true });
}
var Y = M.util.get_string_yui_instance;
}

if (!M.str.hasOwnProperty(component) || !M.str[component].hasOwnProperty(identifier)) {
Expand Down

0 comments on commit db68bd4

Please sign in to comment.