How to minify javascript files or make plug in?

How to minify javascript files or make plug in?

by Ian L -
Number of replies: 2

Did some test on gtmetrix with my site and they suggest minifying javascript files. How can I make a plug in to do this?

course.mysite.com/theme/yui_combo.php?rollup/3.15.0_1/yui-moodlesimple.js&rollup/1518665877/mcore-debug.js could save 188.1KiB (64% reduction) after compression. 

course.mysite.com/theme/yui_combo.php?3.15.0/plugin/plugin.js&3.15.0/event-mousewheel/event-mousewheel.js&3.15.0/event-resize/event-resize.js&3.15.0/event-hover/event-hover.js&3.15.0/event-touch/event-touch.js&3.15.0/event-move/event-move.js&3.15.0/event-flick/event-flick.js&3.15.0/event-valuechange/event-valuechange.js&3.15.0/event-tap/event-tap.js could save 10.0KiB (62% reduction) after compression. 

course.mysite.com/theme/yui_combo.php?m/1518665877/block_navigation/navigation/navigation-debug.js could save 3.5KiB (50% reduction) after compression. 

course.mysite.com/theme/yui_combo.php?m/1518665877/theme_bootstrapbase/bootstrap/bootstrap-debug.js could save 3.3KiB (59% reduction) after compression. 

course.mysite.com/theme/yui_combo.php?m/1518665877/core/event/event-debug.js&m/1518665877/filter_mathjaxloader/loader/loader-debug.js could save 1.4KiB (66% reduction) after compression. 

course.mysite.com/theme/yui_combo.php?m/1518665877/core/lockscroll/lockscroll-debug.jscould save 842B (55% reduction) after compression. 

google-analytics.com/ga.js could save 139B (1% reduction) after compression. 

course.mysite.com/cdn-cgi/scripts/d07b1474/cloudflare-static/email-decode.min.js could save 3B (1% reduction) after compression. 

course.mysite.com/theme/javascript.php/clean/1518723102/footer could save 3B (1% reduction) after compression. 



Average of ratings: -
In reply to Ian L

Re: How to minify javascript files or make plug in?

by Ian L -

Anybody? I am surprised there isn't anything out there like this in Moodle. 

In reply to Ian L

Re: How to minify javascript files or make plug in?

by Davo Smith -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

All of the Moodle JavaScript is minified before it is released. Most of the items you have listed are legacy YUI modules, that are unlikely to get any attention, as they are gradually being replaced. The only one I notice from your list that appears to be a modern AMD module, only claims a 1% possible reduction, which isn't really worth pursuing.

It might be worth double-checking that your are serving the fully minified versions of the YUI files - compare what is served with the smallest versions of those files on the server.