PluginProbe ʕ •ᴥ•ʔ
10Web Booster – Website speed optimization, Cache & Page Speed optimizer / trunk
10Web Booster – Website speed optimization, Cache & Page Speed optimizer vtrunk
2.33.0 2.30.5 2.30.7 2.30.9 2.31.10 2.31.8 2.32.11 2.32.21 2.32.3 2.32.4 2.32.7 2.6.31 2.6.40 2.6.42 2.6.7 2.7.37 2.7.44 2.7.47 2.8.18 2.8.19 2.8.32 2.8.34 2.8.35 2.9.23 2.9.24 2.9.25 2.9.27 v2.27.4 trunk 2.0.10 2.0.11 2.0.12 2.0.13 2.0.14 2.0.15 2.0.17 2.0.18 2.0.21 2.0.22 2.0.25 2.0.26 2.0.27 2.0.3 2.0.7 2.0.9 2.10.46 2.10.65 2.10.66 2.10.68 2.11.41 2.11.42 2.11.43 2.12.15 2.12.21 2.12.22 2.12.23 2.12.26 2.13.37 2.13.40 2.13.41 2.13.42 2.13.44 2.13.45 2.13.47 2.14.49 2.14.50 2.15.18 2.17.21 2.17.23 2.18.17 2.19.44 2.19.45 2.19.46 2.19.49 2.2.12 2.2.15 2.2.16 2.2.18 2.2.8 2.20.31 2.20.32 2.20.33 2.21.11 2.21.12 2.21.16 2.21.25 2.22.32 2.23.13 2.23.15 2.23.16 2.23.18 2.24.12 2.24.14 2.24.18 2.25.14 2.26.6 2.28.10 2.28.13 2.28.14 2.28.7 2.29.1 2.29.2 2.29.3 2.3.0 2.3.1 2.3.2 2.3.3 2.30.18
tenweb-speed-optimizer / includes / external / js / two_delay.js
tenweb-speed-optimizer / includes / external / js Last commit date
vanilla-lazyload 2 months ago jquery.lazy.av.min.js 4 years ago jquery.lazy.iframe.min.js 4 years ago jquery.lazy.js 3 years ago jquery.lazy.min.js 3 years ago lazyload.min.js 4 years ago loader.js 3 years ago two_delay.js 2 years ago two_elementor_video_to_iframe.js 4 years ago two_lazyload.js 3 years ago two_merge_google_font_faces.js 3 years ago two_worker.js 2 years ago two_yt_vi_lazyload.js 3 years ago two_yt_vi_lazyload.min.js 3 years ago
two_delay.js
253 lines
1 two_worker_styles_list = [];
2 two_worker_styles_count = 0;
3
4 var two_script_list = typeof two_worker_data_js === "undefined" ? [] : two_worker_data_js.js;
5 var two_excluded_js_list = typeof two_worker_data_excluded_js === "undefined" ? [] : two_worker_data_excluded_js.js;
6 var excluded_count = two_excluded_js_list.filter((el) => {return !!el['url']}).length;
7 var two_css_list = typeof two_worker_data_css === "undefined" ? [] : two_worker_data_css.css;
8 var two_fonts_list = typeof two_worker_data_font === "undefined" ? [] : two_worker_data_font.font;
9 var two_critical_data = typeof two_worker_data_critical_data === "undefined" ? [] : two_worker_data_critical_data.critical_data;
10 var wcode = new Blob([
11 document.querySelector("#two_worker").textContent
12 ], { type: "text/javascript" });
13
14 var two_worker = new Worker(window.URL.createObjectURL(wcode) );
15 var two_worker_data = {"js" : two_script_list, "excluded_js":two_excluded_js_list , "css": two_css_list , "font":two_fonts_list, critical_data:two_critical_data}
16 two_worker.postMessage(two_worker_data);
17 two_worker.addEventListener("message",function(e) {
18 var data = e.data;
19 if(data.type === "css" && data.status === "ok"){
20 if(data.two_uncritical_fonts && two_font_actions == "exclude_uncritical_fonts"){
21 let two_uncritical_fonts = data.two_uncritical_fonts;
22 const two_font_tag = document.createElement("style");
23 two_font_tag.innerHTML = two_uncritical_fonts;
24 two_font_tag.className = "two_uncritical_fonts";
25 document.body.appendChild(two_font_tag);
26 }
27 if(window.two_page_loaded){
28 two_connect_style(data);
29 }else{
30 two_worker_styles_list.push(data);
31 }
32 } else if(data.type === "js"){
33 if(data.status === "ok") {
34 if(data.excluded_from_delay){
35 two_excluded_js_list[data.id].old_url = two_excluded_js_list[data.id].url;
36 two_excluded_js_list[data.id].url = data.url;
37 two_excluded_js_list[data.id].success = true;
38 excluded_count--;
39 if(excluded_count === 0) {
40 two_connect_script(0, two_excluded_js_list)
41 }
42 }else{
43 two_script_list[data.id].old_url = two_script_list[data.id].url;
44 two_script_list[data.id].url = data.url;
45 two_script_list[data.id].success = true;
46 }
47 }
48 } else if (data.type === "css" && data.status === "error") {
49 console.log("error in fetching, connecting style now")
50 two_connect_failed_style(data);
51 } else if(data.type === "font"){
52 two_connect_font(data);
53 }
54 });
55
56 function UpdateQueryString(key, value, url) {
57 if (!url) url = window.location.href;
58 var re = new RegExp("([?&])" + key + "=.*?(&|#|$)(.*)", "gi"),
59 hash;
60
61 if (re.test(url)) {
62 if (typeof value !== "undefined" && value !== null) {
63 return url.replace(re, "$1" + key + "=" + value + "$2$3");
64 }
65 else {
66 hash = url.split("#");
67 url = hash[0].replace(re, "$1$3").replace(/(&|\?)$/, "");
68 if (typeof hash[1] !== "undefined" && hash[1] !== null) {
69 url += "#" + hash[1];
70 }
71 return url;
72 }
73 }
74 else {
75 if (typeof value !== "undefined" && value !== null) {
76 var separator = url.indexOf("?") !== -1 ? "&" : "?";
77 hash = url.split("#");
78 url = hash[0] + separator + key + "=" + value;
79 if (typeof hash[1] !== "undefined" && hash[1] !== null) {
80 url += "#" + hash[1];
81 }
82 return url;
83 }
84 else {
85 return url;
86 }
87 }
88 }
89
90 function two_connect_failed_style(data) {
91 var link = document.createElement("link");
92 link.className = "fallback_two_worker";
93 link.rel = "stylesheet";
94 link.type = "text/css";
95
96 link.href = data.url;
97 link.media = "none";
98 link.onload = function () { if(this.media==="none"){ if (data.media) {this.media=data.media;}else{this.media="all";}console.log(data.media);} if(data.connected_length == data.length && typeof two_replace_backgrounds != "undefined"){two_replace_backgrounds();}; two_styles_loaded()};
99 document.getElementsByTagName("head")[0].appendChild(link);
100 if(data.connected_length == data.length && typeof two_replace_backgrounds != "undefined"){
101 two_replace_backgrounds();
102 }
103 }
104
105 function two_connect_style(data, fixed_google_font=false) {
106
107 if(fixed_google_font === false && typeof two_merge_google_fonts !== "undefined" && data['original_url'] && data['original_url'].startsWith('https://fonts.googleapis.com/css') && data['response']){
108 data['response'].text().then(function (content){
109 content = two_merge_google_fonts(content)
110
111 let blob = new Blob([content], { type: data['response'].type });
112 data['url'] = URL.createObjectURL(blob);
113 two_connect_style(data, true);
114 });
115
116 return;
117 }
118
119 var link = document.createElement("link");
120 link.className = "loaded_two_worker";
121 link.rel = "stylesheet";
122 link.type = "text/css";
123 link.href = data.url;
124 link.media = data.media;
125 link.onload = function () {if(data.connected_length == data.length && typeof two_replace_backgrounds != "undefined"){two_replace_backgrounds();};two_styles_loaded()};
126 link.onerror = function () {two_styles_loaded()};
127 document.getElementsByTagName("head")[0].appendChild(link);
128 }
129
130 var two_event ;
131
132 function two_connect_script(i, scripts_list=null) {
133
134 if(i === 0 && event){
135 two_event = event;
136 event.preventDefault();
137 }
138
139 if(scripts_list === null){
140 scripts_list = two_script_list;
141 }
142
143 if(typeof scripts_list[i] !== "undefined"){
144 let data_uid = "[data-two_delay_id=\""+scripts_list[i].uid+"\"]";
145 let current_script = document.querySelector(data_uid);
146
147 let script = document.createElement("script");
148 script.type = "text/javascript";
149 script.async = false;
150 if(scripts_list[i].inline){
151 // Decode previously encoded script to get unicode characters working.
152 var js_code = decodeURIComponent( atob( scripts_list[i].code ) );
153 var blob = new Blob([js_code], {type : "text/javascript"});
154 scripts_list[i].url = URL.createObjectURL(blob);
155 }
156 if(current_script != null && typeof scripts_list[i].url != "undefined"){
157 script.dataset.src= scripts_list[i].url;
158 current_script.parentNode.insertBefore(script, current_script);
159 current_script.getAttributeNames().map(
160 function (name){
161 let value = current_script.getAttribute(name);
162 try{
163 script.setAttribute(name, value);
164 }catch(error){
165 console.log(error);
166 }
167 }
168 );
169 current_script.remove();
170 script.classList.add("loaded_two_worker_js");
171 if(typeof scripts_list[i].exclude_blob != "undefined" && scripts_list[i].exclude_blob ){
172 script.dataset.blob_exclude = "1";
173 }
174 }
175 i++;
176 two_connect_script(i, scripts_list);
177
178 } else {
179 let elementor_frontend_js = null;
180 document.querySelectorAll(".loaded_two_worker_js").forEach((elem) => {
181 let id = elem.getAttribute("id");
182 /*We load this JS last so that the all the elementor widgets' js files have already been loaded*/
183 if(id != 'elementor-frontend-js') {
184 two_load_delayed_js(elem);
185 }else{
186 elementor_frontend_js = elem;
187 }
188 });
189 if(elementor_frontend_js !== null){
190 two_load_delayed_js(elementor_frontend_js);
191 }
192 }
193 }
194 function two_load_delayed_js(elem){
195 let data_src = elem.dataset.src;
196 if(elem.dataset.blob_exclude === "1"){
197 delete elem.dataset.blob_exclude;
198 delete elem.dataset.src;
199 delete elem.dataset.two_delay_id;
200 delete elem.dataset.two_delay_src;
201 }
202 if (data_src){
203 elem.setAttribute("src",data_src);
204 }
205 }
206
207 function two_connect_font(data){
208 let font_face = data.font_face;
209
210 if(font_face.indexOf("font-display")>=0){
211 const regex = /font-display:[ ]*[a-z]*[A-Z]*;/g;
212 while ((m = regex.exec(font_face)) !== null) {
213 if (m.index === regex.lastIndex) {
214 regex.lastIndex++;
215 }
216
217 m.forEach((match, groupIndex) => {
218 console.log(match);
219 font_face.replace(match, "font-display: swap;");
220 });
221 }
222 }else{
223 font_face = font_face.replace("}", ";font-display: swap;}");
224 }
225 if(typeof data.main_url != "undefined"){
226 font_face = font_face.replace(data.main_url, data.url);
227 }
228 var newStyle = document.createElement("style");
229 newStyle.className = "two_critical_font";
230 newStyle.appendChild(document.createTextNode(font_face));
231 document.head.appendChild(newStyle);
232 }
233 let connect_stile_timeout = setInterval(function (){
234 console.log(window.two_page_loaded);
235 if(window.two_page_loaded){
236 clearInterval(connect_stile_timeout);
237 two_worker_styles_list.forEach(function(item, index){
238 two_connect_style(item);
239 });
240 two_worker_styles_list = [];
241 }
242 },500);
243 function two_styles_loaded() {
244 if (two_css_list.length - ++two_worker_styles_count == 0) {
245 var critical_css = document.getElementById( "two_critical_css" );
246 if ( critical_css ) {
247 critical_css.remove();
248 }
249 onStylesLoadEvent = new Event( "two_css_loaded" );
250 window.dispatchEvent( onStylesLoadEvent );
251 }
252 }
253