diff options
author | 2018-06-13 16:43:42 +0100 | |
---|---|---|
committer | 2018-06-13 16:43:42 +0100 | |
commit | be2bbe35cf49763ad0258c005f3cbdddd7a21d75 (patch) | |
tree | 962d5e52f4bb57c397c068ae6a11b57952cfc459 /static/js/fouc.js | |
parent | [DB] Attempt reconnection if current connection was lost (diff) |
Compile as much JS with Gulp as possible
This will concatenate ALL of our JS, and minify it - thus leaving us with a single file to be loaded.
There's a few libraries we can't do this with, unfortunately - these are now added in fouc.js:
* Ace Editor
* Flatpickr
* Font-Awesome
Diffstat (limited to 'static/js/fouc.js')
-rw-r--r-- | static/js/fouc.js | 38 |
1 files changed, 0 insertions, 38 deletions
diff --git a/static/js/fouc.js b/static/js/fouc.js deleted file mode 100644 index 01354863..00000000 --- a/static/js/fouc.js +++ /dev/null @@ -1,38 +0,0 @@ -"use strict"; - -function getScript(url, integrity, crossorigin){ - const script = document.createElement("script"); - script.type = "text/javascript"; - script.src = url; - script.defer = true; - script.integrity = integrity; - script.crossOrigin = crossorigin; - document.getElementsByTagName("head")[0].appendChild(script); -} - -function setClass(selector, myClass) { - const element = document.querySelector(selector); - // console.log(element); - element.className = myClass; -} - -function removeClass(selector, myClass) { - const element = document.querySelector(selector); - const reg = new RegExp(`(^| )${myClass}($| )`, "g"); - element.className = element.className.replace(reg, " "); -} - -// hide the html when the page loads, but only if js is turned on. -setClass("html", "prevent-fouc"); - -// when the DOM has finished loading, unhide the html -document.onreadystatechange = function () { - if (document.readyState === "interactive") { - removeClass("html", "prevent-fouc"); - getScript( - "https://pro.fontawesome.com/releases/v5.0.13/js/all.js", // URL - "sha384-d84LGg2pm9KhR4mCAs3N29GQ4OYNy+K+FBHX8WhimHpPm86c839++MDABegrZ3gn", // Integrity - "anonymous" // Cross-origin - ); - } -}; |