diff --git a/common/templates/mathjax_include.html b/common/templates/mathjax_include.html index 01f24ffa60..cbae907011 100644 --- a/common/templates/mathjax_include.html +++ b/common/templates/mathjax_include.html @@ -5,8 +5,11 @@ ## MathJax configuration for Studio lives in ## cms/js/require-config.js. +<%page args="disable_fast_preview=True" expression_filter="h"/> -<%page args="disable_fast_preview=True"/> +## Avoid loading mathjax if already loaded on the page + +%if context.get('load_mathjax', True): %if disable_fast_preview: +%endif diff --git a/lms/djangoapps/courseware/views/views.py b/lms/djangoapps/courseware/views/views.py index 97ab513cbc..a75b3d5fd9 100644 --- a/lms/djangoapps/courseware/views/views.py +++ b/lms/djangoapps/courseware/views/views.py @@ -629,6 +629,10 @@ class CourseTabView(EdxFragmentView): 'uses_pattern_library': not uses_bootstrap, 'disable_courseware_js': True, } + # Avoid Multiple Mathjax loading on the 'user_profile' + if 'profile_page_context' in kwargs: + context['load_mathjax'] = kwargs['profile_page_context'].get('load_mathjax', True) + context.update( get_experiment_user_metadata_context( course, diff --git a/lms/djangoapps/discussion/views.py b/lms/djangoapps/discussion/views.py index 8d08a1090f..cee186baee 100644 --- a/lms/djangoapps/discussion/views.py +++ b/lms/djangoapps/discussion/views.py @@ -581,6 +581,12 @@ def user_profile(request, course_key, user_id): }) else: tab_view = CourseTabView() + + # To avoid mathjax loading from 'mathjax_include.html' + # as that file causes multiple loadings of Mathjax on + # 'user_profile' page + context['load_mathjax'] = False + return tab_view.get(request, unicode(course_key), 'discussion', profile_page_context=context) except User.DoesNotExist: raise Http404 diff --git a/lms/envs/common.py b/lms/envs/common.py index 38c51d452b..3c4223fc07 100644 --- a/lms/envs/common.py +++ b/lms/envs/common.py @@ -1426,7 +1426,6 @@ dashboard_js = ( sorted(rooted_glob(PROJECT_ROOT / 'static', 'js/dashboard/**/*.js')) ) discussion_js = ( - rooted_glob(COMMON_ROOT / 'static', 'common/js/discussion/mathjax_include.js') + rooted_glob(PROJECT_ROOT / 'static', 'js/customwmd.js') + rooted_glob(PROJECT_ROOT / 'static', 'js/mathjax_accessible.js') + rooted_glob(PROJECT_ROOT / 'static', 'js/mathjax_delay_renderer.js') +