Prevent unnecessary loading of fallback iframe when Javascript is disabled.

This commit is contained in:
ccd0 2014-12-21 12:24:01 -08:00
parent ab40bfbe69
commit 44cd4d842a
3 changed files with 7 additions and 5 deletions

View File

@ -41,7 +41,7 @@ Main =
# set up CSS when <head> is completely loaded
$.asap (-> doc = d.documentElement), ->
$.onExists doc, 'body', Main.initStyle
$.onExists doc, 'body', false, Main.initStyle
initFeatures: ->
switch location.hostname

View File

@ -114,15 +114,14 @@ $.asap = (test, cb) ->
else
setTimeout $.asap, 25, test, cb
$.onExists = (root, selector, cb) ->
$.onExists = (root, selector, subtree, cb) ->
if el = $ selector, root
return cb el
observer = new MutationObserver ->
if el = $ selector, root
observer.disconnect()
cb el
observer.observe root,
childList: true
observer.observe root, {childList: true, subtree}
$.addStyle = (css, id, test) ->
style = $.el 'style',

View File

@ -30,7 +30,10 @@ QR =
Header.addShortcut sc
if Conf['Hide Original Post Form']
$.asap (-> doc), -> $.addClass doc, 'hide-original-post-form'
$.addClass doc, 'hide-original-post-form'
if !doc.dataset.jsEnabled
# Prevent unnecessary loading of fallback iframe.
$.onExists doc, '#postForm noscript', true, $.rm
$.on d, '4chanXInitFinished', @initReady