Issue Details (XML | Word | Printable)

Key: MDL-16693
Type: Sub-task Sub-task
Status: Resolved Resolved
Resolution: Fixed
Priority: Minor Minor
Assignee: Tim Hunt
Reporter: Tim Hunt
Votes: 0
Watchers: 0
Operations

Add/Edit UI Mockup to this issue
If you were logged in you would be able to see more operations.
Moodle
MDL-16583

Change require_js so JavaScript is included in the page footer by default, but with an option to output it sooner

Created: 26/Sep/08 12:01 PM   Updated: 12/Jun/09 07:33 PM
Return to search
Component/s: Lib
Affects Version/s: 2.0
Fix Version/s: 2.0

Participants: Tim Hunt
Security Level: None
Resolved date: 12/Jun/09
Affected Branches: MOODLE_20_STABLE
Fixed Branches: MOODLE_20_STABLE


 Description  « Hide
The advice about improving the performance of web pages is to put the JavaScript in the footer of the page. This lets the actual content can load more quickly, so the user can get on with things. JavaScript that just sets up event handlers, and the libraries required to do this, can safely be loaded later.

Therefore, add an optional $loadimmediately argument to require_js that defaults to false. When it is false, the include link is only printed in the page footer. When it is true, the link is output according to the current logic.

 All   Comments   Change History   Version Control      Sort Order: Ascending order - Click to sort in descending order
Tim Hunt made changes - 26/Sep/08 12:12 PM
Field Original Value New Value
Description The advice about improving the performance of web pages is to put the JavaScript in the footer of the page. This lets the actual content can load more quickly, so the user can get on with things. JavaScript that just sets up event handlers, and the libraries required to do this, can safely be loaded later.

Therefore, add an optional $requiredimmediately argument to require_js that defaults to false. When it is false, the include link is only printed in the page footer. When it is true, the link is output according to the current logic.
The advice about improving the performance of web pages is to put the JavaScript in the footer of the page. This lets the actual content can load more quickly, so the user can get on with things. JavaScript that just sets up event handlers, and the libraries required to do this, can safely be loaded later.

Therefore, add an optional $loadimmediately argument to require_js that defaults to false. When it is false, the include link is only printed in the page footer. When it is true, the link is output according to the current logic.
Summary Change fequire_js so JavaScript is included in the page footer by default, but with an option to output it sooner. Change require_js so JavaScript is included in the page footer by default, but with an option to output it sooner
Tim Hunt added a comment - 12/Jun/09 07:33 PM
Thanks to the changes in MDL-16693, this is now effectively done.

Tim Hunt made changes - 12/Jun/09 07:33 PM
Status Open [ 1 ] Resolved [ 5 ]
Resolution Fixed [ 1 ]
tjhunt committed 36 files to 'Moodle CVS' - 12/Jun/09 08:13 PM
ajaxlib/require_js: MDL-16693 $PAGE->requires->... deprecates require_js etc.

There is a new implementation of require_js in lib/deprecatedlib.php,
based on $PAGE->requires.

There were a few other recently introduced functions in lib/weblib.php,
namely print_js_call, print_delayed_js_call, print_js_config and
standard_js_config. These have been removed, since they were never in
a stable branch, and all the places that used them have been changed
to use the newer $PAGE->requires->... methods.

get_require_js_code is also gone, and the evil places that were calling
it, even though it is an internal function, have been fixed.

Also, I made some minor improvements to the code I committed yesterday
for MDL-16695.

All that remains is to update all the places in core code that are
still using require_js.

(This commit also fixes the problem where the admin tree would not
start with the right categories expanded.)
MODIFY question/type/questiontype.php   Rev. 1.126    (+5 -5 lines)
MODIFY course/view.php   Rev. 1.127    (+17 -35 lines)
MODIFY lib/ajax/simpletest/testajaxlib.php   Rev. 1.5    (+4 -13 lines)
MODIFY mod/quiz/attemptlib.php   Rev. 1.39    (+4 -7 lines)
MODIFY blocks/admin_tree/block_admin_tree.php   Rev. 1.42    (+12 -12 lines)
MODIFY mod/quiz/review.php   Rev. 1.90    (+2 -2 lines)
MODIFY mod/quiz/quiz.js   Rev. 1.17    (+1 -1 lines)
MODIFY mod/forum/lib.php   Rev. 1.792    (+2 -2 lines)
MODIFY lib/recaptchalib.php   Rev. 1.10    (+1 -1 lines)
MODIFY lib/form/datetimeselector.php   Rev. 1.18    (+2 -2 lines)
MODIFY repository/lib.php   Rev. 1.180    (+6 -4 lines)
MODIFY mod/quiz/accessrules.php   Rev. 1.22    (+3 -2 lines)
MODIFY admin/roles/lib.php   Rev. 1.23    (+5 -5 lines)
MODIFY course/completion.js   Rev. 1.6    (+1 -7 lines)
MODIFY lib/formslib.php   Rev. 1.178    (+6 -9 lines)
MODIFY lib/questionlib.php   Rev. 1.197    (+2 -2 lines)
MODIFY admin/xmldb/Attic/javascript.php   Rev. 1.6    (+9 -11 lines)
MODIFY lib/filelib.php   Rev. 1.151    (+1 -1 lines)
MODIFY mod/chat/gui_ajax/index.php   Rev. 1.10    (+4 -4 lines)
MODIFY question/editlib.php   Rev. 1.120    (+9 -7 lines)
MODIFY lib/ajax/ajaxlib.php   Rev. 1.55    (+57 -110 lines)
MODIFY admin/report/spamcleaner/index.php   Rev. 1.6    (+3 -3 lines)
MODIFY admin/report/capability/index.php   Rev. 1.11    (+4 -4 lines)
MODIFY lib/pagelib.php   Rev. 1.119    (+1 -1 lines)
MODIFY admin/roles/assign.php   Rev. 1.98    (+4 -4 lines)
MODIFY message/refresh.php   Rev. 1.19    (+8 -5 lines)
MODIFY question/export.php   Rev. 1.51    (+2 -2 lines)
MODIFY lib/weblib.php   Rev. 1.1262    (+24 -273 lines)
MODIFY lib/moodlelib.php   Rev. 1.1213    (+3 -4 lines)
MODIFY group/members.php   Rev. 1.19    (+3 -3 lines)
MODIFY mod/quiz/edit.php   Rev. 1.153    (+3 -3 lines)
MODIFY calendar/lib.php   Rev. 1.231    (+6 -3 lines)
MODIFY user/selector/lib.php   Rev. 1.20    (+12 -7 lines)
MODIFY lib/form/dateselector.php   Rev. 1.16    (+2 -2 lines)
MODIFY lib/deprecatedlib.php   Rev. 1.111    (+35 -0 lines)
MODIFY mod/quiz/attempt.php   Rev. 1.162    (+9 -4 lines)
Sam Hemelryk committed 2 files to 'Moodle CVS' - 22/Jun/09 10:59 AM
ajaxlib MDL-16693 Fixed fringe condition in ajaxlib and added test
MODIFY lib/ajax/ajaxlib.php   Rev. 1.61    (+2 -1 lines)
MODIFY lib/ajax/simpletest/testajaxlib.php   Rev. 1.7    (+9 -0 lines)
Jerome Mouneyrac committed 1 file to 'Moodle CVS' - 24/Jun/09 03:39 PM
javascript MDL-16693 Tim's fix for recaptcha
MODIFY lib/recaptchalib.php   Rev. 1.11    (+2 -2 lines)
tjhunt committed 1 file to 'Moodle CVS' - 17/Jul/09 03:46 PM
admin block: MDL-16693 fix todo.
MODIFY blocks/admin_tree/block_admin_tree.php   Rev. 1.46    (+2 -3 lines)