forked from mobify/mobifyjs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mobify-custom.js.example
37 lines (30 loc) · 1.4 KB
/
mobify-custom.js.example
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
require(["mobifyjs/utils", "mobifyjs/capture", "mobifyjs/resizeImages", "mobifyjs/jazzcat", "mobifyjs/unblockify", "mobifyjs/firefox"], function(Utils, Capture, ResizeImages, Jazzcat, Unblockify, Firefox) {
var Mobify = window.Mobify = window.Mobify || {};
// DECLARE LIBRARIES ATTACHED TO MOBIFY OBJECT HERE
Mobify.Utils = Utils;
Mobify.Capture = Capture;
Mobify.ResizeImages = ResizeImages;
Mobify.Jazzcat = Jazzcat;
Mobify.Unblockify = Unblockify;
Mobify.api = "2.0"; // v6 tag backwards compatibility change
Mobify.Capture = Capture;
Mobify.ResizeImages = ResizeImages;
// OPTIONAL: Also add main executable logic to compile library + main
// instead of having seperate main.js file
var capturing = window.Mobify && window.Mobify.capturing || false;
if (capturing) {
// Grab reference to a newly created document
Mobify.Capture.initCapture(function(capture){
// optimize scripts
var capturedDoc = capture.capturedDoc;
//var scripts = capturedDoc.querySelectorAll('script');
//Mobify.Jazzcat.optimizeScripts(scripts);
// optimize images
var images = capturedDoc.querySelectorAll('img, picture');
Mobify.ResizeImages.resize(images);
capture.renderCapturedDoc();
});
} else {
}
}, undefined, true);
// relPath, forceSync