Spaces:
Running
Running
Download loader.js from mxraiis/newbiel-project: direct link, hf CLI and curl.
- Browser
- Download file 2.25 kB
-
https://huggingface.co/spaces/mxraiis/newbiel-project/resolve/main/loader.js
- Command line
-
hf download hf://spaces/mxraiis/newbiel-project/loader.js
-
curl -L -o loader.js https://huggingface.co/spaces/mxraiis/newbiel-project/resolve/main/loader.js
2.25 kB
| (function () { | |
| "use strict"; | |
| var reduced = false; | |
| try { | |
| reduced = window.matchMedia("(prefers-reduced-motion: reduce)").matches; | |
| } catch (e) {} | |
| var mobile = false; | |
| try { | |
| mobile = window.matchMedia("(max-width: 850px)").matches; | |
| } catch (e2) {} | |
| var conn = navigator.connection || navigator.mozConnection || navigator.webkitConnection; | |
| var saveData = !!(conn && (conn.saveData || /2g|slow-2g/i.test(conn.effectiveType || ""))); | |
| var want3D = !reduced && !saveData && !mobile; | |
| var wantGsap = !reduced && !saveData; | |
| function loadScript(src, integrity) { | |
| return new Promise(function (resolve, reject) { | |
| var s = document.createElement("script"); | |
| s.src = src; | |
| s.async = true; | |
| if (integrity) { | |
| s.integrity = integrity; | |
| s.crossOrigin = "anonymous"; | |
| } | |
| try { s.fetchPriority = "low"; } catch (e) {} | |
| s.onload = function () { resolve(src); }; | |
| s.onerror = function () { reject(new Error("fail " + src)); }; | |
| document.head.appendChild(s); | |
| }); | |
| } | |
| var queue = []; | |
| if (wantGsap) { | |
| queue.push( | |
| loadScript("https://cdn.jsdelivr.net/npm/gsap@3.12.5/dist/gsap.min.js", "sha384-g4NTh/Iv5PPU4xPyhEWqPcwtNXOvdaDI8LLnyYfyNZOjKJeYQyjzQ9X5275eBjpt").then(function () { | |
| return loadScript("https://cdn.jsdelivr.net/npm/gsap@3.12.5/dist/ScrollTrigger.min.js", "sha384-Z3REaz79l2IaAZqJsSABtTbhjgOUYyV3p90XNnAPCSHg3EMTz1fouunq9WZRtj3d"); | |
| }) | |
| ); | |
| } | |
| if (want3D) { | |
| queue.push( | |
| loadScript("https://cdn.jsdelivr.net/npm/three@0.160.0/build/three.min.js", "sha384-qOkzR5Ke/XkQxuGVJ9hpFEpDlcoLtWwVYhnJf06cLIZa2vaIptSqaubivErzmD5O").then(function () { | |
| return loadScript("scene3d.js"); | |
| }) | |
| ); | |
| } else { | |
| var canvas = document.querySelector("[data-journey-canvas]"); | |
| if (canvas) { | |
| canvas.style.display = "none"; | |
| canvas.setAttribute("data-webgl-disabled", "loader-skipped"); | |
| } | |
| } | |
| window.NEWBIEL_LOADER = { | |
| want3D: want3D, | |
| wantGsap: wantGsap, | |
| ready: Promise.all(queue.map(function (p) { | |
| return p.catch(function () { return null; }); | |
| })) | |
| }; | |
| window.NEWBIEL_LOADER.ready.then(function () { | |
| window.dispatchEvent(new CustomEvent("newbiel:deps")); | |
| }); | |
| }()); | |