From 4eb95737b5fdcc8410a74dacfce962a461bf2013 Mon Sep 17 00:00:00 2001 From: Toby Lawrence Date: Wed, 9 Mar 2016 16:55:47 -0500 Subject: [PATCH] Update and take advantage of our ability to override RequireJS paths. We had a mechanism to, at runtime, generate a RequireJS config that would override the base paths and, instead, use the hashed versions of assets for things that RequireJs was loading on demand. We've now moved that out of the coureware.html base template and into main.html so that more pages actually benefit from it. As well, we've added some of the heavy hitters for unhashed assets, namely moment.min.js, to these overrides which should allow better caching for end users. We'll be able to add more things to the override list in the future as they crop up. --- lms/envs/common.py | 6 +++++- lms/templates/courseware/courseware.html | 5 ----- lms/templates/main.html | 3 ++- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/lms/envs/common.py b/lms/envs/common.py index 32e05c0821..5643e82999 100644 --- a/lms/envs/common.py +++ b/lms/envs/common.py @@ -1633,7 +1633,11 @@ REQUIRE_ENVIRONMENT = "node" # then you need to add the js urls in this list. REQUIRE_JS_PATH_OVERRIDES = [ 'js/bookmarks/views/bookmark_button.js', - 'js/views/message_banner.js' + 'js/views/message_banner.js', + 'js/vendor/moment.min.js', + 'js/vendor/url.min.js', + 'js/courseware/course_home_events.js', + 'js/courseware/toggle_element_visibility.js' ] ################################# CELERY ###################################### diff --git a/lms/templates/courseware/courseware.html b/lms/templates/courseware/courseware.html index 459361806a..2c55941012 100644 --- a/lms/templates/courseware/courseware.html +++ b/lms/templates/courseware/courseware.html @@ -5,7 +5,6 @@ from django.utils.translation import ugettext as _ from django.template.defaultfilters import escapejs from django.conf import settings from edxnotes.helpers import is_feature_enabled as is_edxnotes_enabled -from pipeline_mako import render_require_js_path_overrides %> <% include_special_exams = settings.FEATURES.get('ENABLE_SPECIAL_EXAMS', False) and (course.enable_proctored_exams or course.enable_timed_exams) @@ -16,10 +15,6 @@ from pipeline_mako import render_require_js_path_overrides <%block name="bodyclass">view-in-course view-courseware courseware ${course.css_class or ''} -<%block name="js_overrides"> -${render_require_js_path_overrides(settings.REQUIRE_JS_PATH_OVERRIDES)} - - <%block name="title"> % if section_title: ${static.get_page_title_breadcrumbs(section_title, course_name())} diff --git a/lms/templates/main.html b/lms/templates/main.html index b45f36ee1e..827e578234 100644 --- a/lms/templates/main.html +++ b/lms/templates/main.html @@ -6,6 +6,7 @@ from django.utils.http import urlquote_plus from django.utils.translation import ugettext as _ from django.utils.translation import get_language_bidi from branding import api as branding_api +from pipeline_mako import render_require_js_path_overrides %> <!DOCTYPE html> <!--[if lte IE 9]><html class="ie ie9 lte9" lang="${LANGUAGE_CODE}"><![endif]--> @@ -77,8 +78,8 @@ from branding import api as branding_api }).call(this, require || RequireJS.require); </script> <script type="text/javascript" src="${static.url("lms/js/require-config.js")}"></script> - <%block name="js_overrides"> + ${render_require_js_path_overrides(settings.REQUIRE_JS_PATH_OVERRIDES)} </%block> % if not disable_courseware_js: