Questions tagged [domcontentloaded]

DOM event The DOMContentLoaded event is fired when the document has been completely loaded and parsed, without waiting for stylesheets, images, and subframes to finish loading (the load event can be used to detect a fully-loaded page).

124 questions
68
votes
10 answers

Code inside DOMContentLoaded event not working

I have used
Not Loading...
Jamgreen
  • 10,329
  • 29
  • 113
  • 224
20
votes
3 answers

Why First Paint is happening before DOMContentLoaded

I'm diving into performance tools that are shipped with Google Chrome as I'm trying to get my head around performance improvements techniques. I'm playing around with Timeline tab, and I found that on my page First Paint event is happening before…
dragonfly
  • 17,407
  • 30
  • 110
  • 219
11
votes
3 answers

Feature detect support for DOMContentLoaded event

Is it possible to detect support for the DOMContentLoaded event? Method's like Kangax's solution here won't work because DOMContentLoaded is not exposed as a property of any element: Detecting event support without browser sniffing
10
votes
2 answers

Why DOMContentLoaded handler can block first paint?

There is a similar question that wasn't resolved. I've encountered a situation when handler that listens to DOMContentLoaded can block first paint. Sometimes it blocks, sometimes it doesn't I tried many times cmd + R to see it. Is there any…
Roman Roman
  • 807
  • 9
  • 26
10
votes
3 answers

How does DOMContentLoaded relate to Web Components?

It's age-old common sense to start manipulating the DOM only once it's ready and we can be certain all the elements are available, and in the post-jQuery days we're all using the DOMContentLoaded event for this. Now web components (especially in the…
connexo
  • 53,704
  • 14
  • 91
  • 128
7
votes
4 answers

Order of DOM Execution Issue

I have some JavaScript in the HEAD tag that dynamically inserts an asynchronously loading script tag before the last script on the page (that has been currently parsed). This dynamically included script tag contains JavaScript that needs to parse…
Justin Meltzer
  • 13,318
  • 32
  • 117
  • 182
6
votes
1 answer

window.onload fires before jQuery document.ready in Firefox

I created a Codepen showing the issue: https://codepen.io/samuelg0rd0n/pen/ExVGQEV In Chrome, it correctly fires DOMContentLoaded event and jQuery document ready events before window onload events. However, in Firefox, the order…
samuelg0rd0n
  • 1,080
  • 2
  • 15
  • 27
6
votes
0 answers

DOMContentLoaded and turbolinks:load not triggering on Dynamically loaded scripts with first page load (loaded without turbolinks)

'turbolinks:load' is not getting triggered on the directly loaded pages but, on the pages loaded with turbolinks 'turbolinks:load' event is working fine. Using this code, alert is…
3
votes
2 answers

Do scripts in the document head always execute before DOMContentLoaded fires?

In the following document, Where example.js is: document.addEventListener('DOMContentLoaded', function () { …
Chris Martin
  • 30,334
  • 10
  • 78
  • 137
1
2 3
8 9