-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex@v0.1.0.html
More file actions
83 lines (76 loc) · 2.9 KB
/
index@v0.1.0.html
File metadata and controls
83 lines (76 loc) · 2.9 KB
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
<!DOCTYPE html>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<title>Hello, World!</title>
<link href="./style.css" rel="stylesheet">
<link rel="prefetch" href="https://cdn.jsdelivr.net/gh/denisde4ev/html-css-js/js/lib/q/q%400.1.0.js" as="script" onload="alert('onload')" onerror="alert('onerror')">
<script>
var req_basepath = 'https://cdn.jsdelivr.net/gh/denisde4ev/html-css-js/js/lib';
// src: https://github.com/denisde4ev/html-css-js/raw/master/js/lib/req/req-synconly@0.1.0-alpha.js
_m = {};
var req=n=>{
if(_m[n=n.replace(/^(https:\/\/)?(.*?)(\.js)?$/,(O,p,n,j)=>(u=p?O:req_basepath+'/'+n+(j||'.js'),n))]){return _m[n].exports}
var u,m={exports:_m[n]={}},x=new XMLHttpRequest();x.open('GET',u,false);x.send();
Function('module, exports',x.responseText+'\n\n//# sourceURL='+u+'\n')(m,_m[n]);
return _m[n]
};
</script>
<script id="js_req" onload="req.basepath=req_basepath,alert(req.modules=_m)" type="disabled" src="https://cdn.jsdelivr.net/gh/denisde4ev/html-css-js/js/lib/req/req%40v0.3.0-alpha.js"></script>
<script>
alert('afterloaded');
{
let a = js_req;
a.remove();
a.removeAttribute('type');
a = a.cloneNode();
a.id += '_';
document.head.appendChild(a);
}
function addPreload_js(url) {
// this function will be used in sync requests, hope browser will make all at the same itme
var el = document.createElement('link');
el.rel = 'preload';
el.href = url;
el.as = 'script';
// Object.assign(el, moreProps);
document.head.appendChild(el);
return el;
}
function prefetch_lazyfn(libName, fnNames, gDefine = true) {
// this function will be used in sync requests, hope browser will make all at the same itme
var url = n.replace(/^(https:\/\/)?(.*?)(\.js)?$/,(O,p,n)=>( p ? O : req_basepath+'/'+n+'.js' ));
var el = document.createElement('link');
el.rel = 'preload';
el.href = url;
el.as = 'script';
// Object.assign(el, moreProps);
document.head.appendChild(el);
if (fnNames) {
var obj = {};
if (typeof fnNames === 'string') fnNames = [fnNames];
for (let fnName of fnNames) {
let lazyFn = function() {
var fn = req(libName)[fnName];
if (gDefine) globalThis[fnName] = fn;
return lib.apply(this, arguments());
} // TODO:!!! check if `let fnName` caching have created different variables for each cached functions
if (gDefine) globalThis[fnName] = fn;
obj[fnName] = fn;
}
}
return {linkEl: el, obj: obj};
}
Q = function waitingMany(names) {
names.forEach(name => {
// NOTE:! for now not expected name to be full url!
addPreload_js(req_basepath + '/' + name + '.js');
});
return names.map(name => req(name));
};
q = function waitingQ(...a) {
return (q=req('q/q%400.1.0').q||q)(...a);
};
</script>
<h1 onclick="q('#content').html('clicked')">click me</h1>
<p id="content"></p>
<script src="./script.js"></script>