Commit 61353234 by Brian Jacobel

Load factory JS files with a synchronous <script> tag in production

parent 7fa763b2
...@@ -78,23 +78,14 @@ source, template_path = Loader(engine).load_template_source(path) ...@@ -78,23 +78,14 @@ source, template_path = Loader(engine).load_template_source(path)
%>${source | n, decode.utf8}</%def> %>${source | n, decode.utf8}</%def>
<%def name="require_module(module_name, class_name)"> <%def name="require_module(module_name, class_name)">
% if not settings.REQUIRE_DEBUG:
<script type="text/javascript" src="${staticfiles_storage.url(module_name + '.js') + '?raw'}"></script>
% endif
<script type="text/javascript"> <script type="text/javascript">
(function (require) { (function (require) {
% if settings.REQUIRE_DEBUG: require(['${module_name | n, js_escaped_string}'], function (${class_name | n, decode.utf8}) {
require(['${module_name | n, js_escaped_string}'], function (${class_name | n, decode.utf8}) { ${caller.body() | n, decode.utf8}
${caller.body() | n, decode.utf8} });
});
% else:
## The "raw" parameter is specified to avoid the URL from being further maninpulated by
## static_replace calls (as woudl happen if require_module is used within courseware).
## Without specifying "raw", a call to static_replace would result in the MD5 hash being
## being appended more than once, causing the import to fail in production environments.
require(['${staticfiles_storage.url(module_name + ".js") + "?raw" | n, js_escaped_string}'], function () {
require(['${module_name | n, js_escaped_string}'], function (${class_name | n, decode.utf8}) {
${caller.body() | n, decode.utf8}
});
});
% endif
}).call(this, require || RequireJS.require); }).call(this, require || RequireJS.require);
</script> </script>
</%def> </%def>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment