OSDN Git Service

Regular updates
[twpd/master.git] / _js / critical.js
1 /*
2  * This is the "critical path" JavaScript that will be included INLINE on every
3  * page. Keep this as small as possible!
4  */
5
6 import wrapify from './wrapify'
7 import addClass from 'dom101/add-class'
8 import on from 'dom101/on'
9
10 // Transform the main body markup to make it readable.
11 const body = document.querySelector('[data-js-main-body]')
12
13 if (body) {
14   wrapify(body)
15   addClass(body, '-wrapified')
16 }
17
18 // Be "done" when we're done, or after a certain timeout.
19 on(window, 'load', done)
20 setTimeout(done, 5000)
21
22 let isDone
23 function done () {
24   if (isDone) return
25   addClass(document.documentElement, 'LoadDone')
26   isDone = true
27 }