 # Initialization tasks that must wait for the document to be ready.
 #
 initializeOnDomReady = ->
-  registerFrame()
-
   enterInsertModeIfElementIsFocused() if isEnabledForUrl
 
   # Tell the background page we're in the dom ready state.

  chrome.runtime.sendMessage(
    handler: "registerFrame"
    frameId: frameId
    is_top: window.top == window.self
    total: frames.length + 1)

# Unregister the frame if we're going to exit.
unregisterFrame = ->

      state.onUpdate(value)

initializePreDomReady()
window.addEventListener("DOMContentLoaded", registerFrame)
window.addEventListener("DOMContentLoaded", initializeOnDomReady)
window.addEventListener("unload", unregisterFrame)

