MDL-57608 media_videojs: lazily load videojs on demand
The videojs javascript is over 1MB of javascript which we don't need to load on every page, now that we only require it demand, the js can be lazily loaded when its needed, which keeps the first.js smaller and more likely to stay in browser cache.
This commit is contained in:
committed by
Marina Glancy
parent
8e8c066448
commit
bf02dc9819
+2
-2
@@ -56,8 +56,8 @@ lib/amd/src/chartjs-lazy.js
|
||||
lib/maxmind/GeoIp2/
|
||||
lib/maxmind/MaxMind/
|
||||
lib/ltiprovider/
|
||||
media/player/videojs/amd/src/video.js
|
||||
media/player/videojs/amd/src/Youtube.js
|
||||
media/player/videojs/amd/src/video-lazy.js
|
||||
media/player/videojs/amd/src/Youtube-lazy.js
|
||||
media/player/videojs/videojs/
|
||||
mod/assign/feedback/editpdf/fpdi/
|
||||
repository/s3/S3.php
|
||||
|
||||
+2
-2
@@ -57,8 +57,8 @@ lib/amd/src/chartjs-lazy.js
|
||||
lib/maxmind/GeoIp2/
|
||||
lib/maxmind/MaxMind/
|
||||
lib/ltiprovider/
|
||||
media/player/videojs/amd/src/video.js
|
||||
media/player/videojs/amd/src/Youtube.js
|
||||
media/player/videojs/amd/src/video-lazy.js
|
||||
media/player/videojs/amd/src/Youtube-lazy.js
|
||||
media/player/videojs/videojs/
|
||||
mod/assign/feedback/editpdf/fpdi/
|
||||
repository/s3/S3.php
|
||||
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+1
-1
@@ -1 +1 @@
|
||||
define(["jquery","core/event"],function(a,b){var c,d=function(d){c=d,e(null,a("body")),b.getLegacyEvents().done(function(b){a(document).on(b.FILTER_CONTENT_UPDATED,e)})},e=function(b,d){var e=".mediaplugin_videojs";d.find(e).addBack(e).find("audio, video").each(function(){var b=a(this).attr("id"),d=a(this).data("setup"),e=["media_videojs/video"];d.techOrder&&d.techOrder.indexOf("youtube")!==-1&&e.push("media_videojs/Youtube"),require(e,function(a){c&&(c(a),c=null),a(b,d)})})};return{setUp:d}});
|
||||
define(["jquery","core/event"],function(a,b){var c,d=function(d){c=d,e(null,a("body")),b.getLegacyEvents().done(function(b){a(document).on(b.FILTER_CONTENT_UPDATED,e)})},e=function(b,d){var e=".mediaplugin_videojs";d.find(e).addBack(e).find("audio, video").each(function(){var b=a(this).attr("id"),d=a(this).data("setup"),e=["media_videojs/video-lazy"];d.techOrder&&d.techOrder.indexOf("youtube")!==-1&&e.push("media_videojs/Youtube-lazy"),require(e,function(a){c&&(c(a),c=null),a(b,d)})})};return{setUp:d}});
|
||||
Vendored
+1
-1
@@ -24,7 +24,7 @@ THE SOFTWARE. */
|
||||
if(typeof exports==='object' && typeof module!=='undefined') {
|
||||
module.exports = factory(require('video.js'));
|
||||
} else if(typeof define === 'function' && define.amd) {
|
||||
define(['media_videojs/video'], function(videojs){
|
||||
define(['media_videojs/video-lazy'], function(videojs){
|
||||
return (root.Youtube = factory(videojs));
|
||||
});
|
||||
} else {
|
||||
@@ -63,11 +63,11 @@ define(['jquery', 'core/event'], function($, Event) {
|
||||
.find('audio, video').each(function() {
|
||||
var id = $(this).attr('id'),
|
||||
config = $(this).data('setup'),
|
||||
modules = ['media_videojs/video'];
|
||||
modules = ['media_videojs/video-lazy'];
|
||||
|
||||
if (config.techOrder && config.techOrder.indexOf('youtube') !== -1) {
|
||||
// Add YouTube to the list of modules we require.
|
||||
modules.push('media_videojs/Youtube');
|
||||
modules.push('media_videojs/Youtube-lazy');
|
||||
}
|
||||
require(modules, function(videojs) {
|
||||
if (onload) {
|
||||
|
||||
@@ -5,7 +5,7 @@ https://github.com/videojs/video.js
|
||||
Instructions to import VideoJS player into Moodle:
|
||||
|
||||
1. Download the latest release from https://github.com/videojs/video.js/releases in a separate directory
|
||||
2. copy 'dist/video.js' into 'amd/src/video.js'
|
||||
2. copy 'dist/video.js' into 'amd/src/video-lazy.js'
|
||||
3. copy 'dist/font/' into 'fonts/' folder
|
||||
4. copy 'dist/video-js.css' into 'styles.css'
|
||||
Replace
|
||||
@@ -21,8 +21,8 @@ Instructions to import VideoJS player into Moodle:
|
||||
|
||||
Import plugins:
|
||||
|
||||
1. Copy https://github.com/videojs/videojs-youtube/blob/master/dist/Youtube.js into 'amd/src/Youtube.js'
|
||||
1. Copy https://github.com/videojs/videojs-youtube/blob/master/dist/Youtube.js into 'amd/src/Youtube-lazy.js'
|
||||
In the beginning of the js file replace
|
||||
define(['videojs']
|
||||
with
|
||||
define(['media_videojs/video']
|
||||
define(['media_videojs/video-lazy']
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
<?xml version="1.0"?>
|
||||
<libraries>
|
||||
<library>
|
||||
<location>amd/src/video.js</location>
|
||||
<location>amd/src/video-lazy.js</location>
|
||||
<name>VideoJS</name>
|
||||
<license>Apache</license>
|
||||
<version>5.12.6</version>
|
||||
<licenseversion></licenseversion>
|
||||
</library>
|
||||
<library>
|
||||
<location>amd/src/Youtube.js</location>
|
||||
<location>amd/src/Youtube-lazy.js</location>
|
||||
<name>YouTube Playback Technology for Video.js</name>
|
||||
<license>MIT</license>
|
||||
<version>2.1.1</version>
|
||||
|
||||
Reference in New Issue
Block a user