From 6829029227cefb2bccaf4262a2a798618e13ab13 Mon Sep 17 00:00:00 2001 From: igoradamenko Date: Sat, 28 Apr 2018 22:46:03 +0300 Subject: [PATCH] fix scripts init --- web/app/counter.js | 2 +- web/app/embed.js | 2 +- web/app/last-comments.js | 2 +- web/app/remark.js | 6 +++++- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/web/app/counter.js b/web/app/counter.js index bd81c8dd..70cd8f0f 100644 --- a/web/app/counter.js +++ b/web/app/counter.js @@ -2,7 +2,7 @@ import { COUNTER_NODE_CLASSNAME } from './common/constants' import api from 'common/api'; -if (document.readyState !== 'interactive') { +if (document.readyState === 'loading') { document.addEventListener('DOMContentLoaded', init); } else { init(); diff --git a/web/app/embed.js b/web/app/embed.js index 1e4ab8e4..60bd56e0 100644 --- a/web/app/embed.js +++ b/web/app/embed.js @@ -1,6 +1,6 @@ import { BASE_URL, NODE_ID } from 'common/constants'; -if (document.readyState !== 'interactive') { +if (document.readyState === 'loading') { document.addEventListener('DOMContentLoaded', init); } else { init(); diff --git a/web/app/last-comments.js b/web/app/last-comments.js index 1fc1ee72..b8880ca5 100644 --- a/web/app/last-comments.js +++ b/web/app/last-comments.js @@ -6,7 +6,7 @@ import api from 'common/api'; import ListComments from 'components/list-comments'; -if (document.readyState !== 'interactive') { +if (document.readyState === 'loading') { document.addEventListener('DOMContentLoaded', init); } else { init(); diff --git a/web/app/remark.js b/web/app/remark.js index 0b28667a..5e504410 100644 --- a/web/app/remark.js +++ b/web/app/remark.js @@ -9,7 +9,11 @@ import { NODE_ID } from './common/constants'; require('./components/document'); -init(); +if (document.readyState === 'loading') { + document.addEventListener('DOMContentLoaded', init); +} else { + init(); +} function init() { const node = document.getElementById(NODE_ID);