PluginProbe ʕ •ᴥ•ʔ
10Web Booster – Website speed optimization, Cache & Page Speed optimizer / 2.33.6
10Web Booster – Website speed optimization, Cache & Page Speed optimizer v2.33.6
2.33.6 2.33.5 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 4 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 1 week ago two_delay.js 1 week 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
255 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 if (typeof two_is_native_editable !== "function" || !two_is_native_editable(event.target)) {
137 event.preventDefault();
138 }
139 }
140
141 if(scripts_list === null){
142 scripts_list = two_script_list;
143 }
144
145 if(typeof scripts_list[i] !== "undefined"){
146 let data_uid = "[data-two_delay_id=\""+scripts_list[i].uid+"\"]";
147 let current_script = document.querySelector(data_uid);
148
149 let script = document.createElement("script");
150 script.type = "text/javascript";
151 script.async = false;
152 if(scripts_list[i].inline){
153 // Decode previously encoded script to get unicode characters working.
154 var js_code = decodeURIComponent( atob( scripts_list[i].code ) );
155 var blob = new Blob([js_code], {type : "text/javascript"});
156 scripts_list[i].url = URL.createObjectURL(blob);
157 }
158 if(current_script != null && typeof scripts_list[i].url != "undefined"){
159 script.dataset.src= scripts_list[i].url;
160 current_script.parentNode.insertBefore(script, current_script);
161 current_script.getAttributeNames().map(
162 function (name){
163 let value = current_script.getAttribute(name);
164 try{
165 script.setAttribute(name, value);
166 }catch(error){
167 console.log(error);
168 }
169 }
170 );
171 current_script.remove();
172 script.classList.add("loaded_two_worker_js");
173 if(typeof scripts_list[i].exclude_blob != "undefined" && scripts_list[i].exclude_blob ){
174 script.dataset.blob_exclude = "1";
175 }
176 }
177 i++;
178 two_connect_script(i, scripts_list);
179
180 } else {
181 let elementor_frontend_js = null;
182 document.querySelectorAll(".loaded_two_worker_js").forEach((elem) => {
183 let id = elem.getAttribute("id");
184 /*We load this JS last so that the all the elementor widgets' js files have already been loaded*/
185 if(id != 'elementor-frontend-js') {
186 two_load_delayed_js(elem);
187 }else{
188 elementor_frontend_js = elem;
189 }
190 });
191 if(elementor_frontend_js !== null){
192 two_load_delayed_js(elementor_frontend_js);
193 }
194 }
195 }
196 function two_load_delayed_js(elem){
197 let data_src = elem.dataset.src;
198 if(elem.dataset.blob_exclude === "1"){
199 delete elem.dataset.blob_exclude;
200 delete elem.dataset.src;
201 delete elem.dataset.two_delay_id;
202 delete elem.dataset.two_delay_src;
203 }
204 if (data_src){
205 elem.setAttribute("src",data_src);
206 }
207 }
208
209 function two_connect_font(data){
210 let font_face = data.font_face;
211
212 if(font_face.indexOf("font-display")>=0){
213 const regex = /font-display:[ ]*[a-z]*[A-Z]*;/g;
214 while ((m = regex.exec(font_face)) !== null) {
215 if (m.index === regex.lastIndex) {
216 regex.lastIndex++;
217 }
218
219 m.forEach((match, groupIndex) => {
220 console.log(match);
221 font_face.replace(match, "font-display: swap;");
222 });
223 }
224 }else{
225 font_face = font_face.replace("}", ";font-display: swap;}");
226 }
227 if(typeof data.main_url != "undefined"){
228 font_face = font_face.replace(data.main_url, data.url);
229 }
230 var newStyle = document.createElement("style");
231 newStyle.className = "two_critical_font";
232 newStyle.appendChild(document.createTextNode(font_face));
233 document.head.appendChild(newStyle);
234 }
235 let connect_stile_timeout = setInterval(function (){
236 console.log(window.two_page_loaded);
237 if(window.two_page_loaded){
238 clearInterval(connect_stile_timeout);
239 two_worker_styles_list.forEach(function(item, index){
240 two_connect_style(item);
241 });
242 two_worker_styles_list = [];
243 }
244 },500);
245 function two_styles_loaded() {
246 if (two_css_list.length - ++two_worker_styles_count == 0) {
247 var critical_css = document.getElementById( "two_critical_css" );
248 if ( critical_css ) {
249 critical_css.remove();
250 }
251 onStylesLoadEvent = new Event( "two_css_loaded" );
252 window.dispatchEvent( onStylesLoadEvent );
253 }
254 }
255