paint-brush
DOM Readiness in Javascriptby@smpnjn
170 reads

DOM Readiness in Javascript

by Johnny Simpson2mOctober 18th, 2022
Read on Terminal Reader
Read this story w/o Javascript
tldt arrow

Too Long; Didn't Read

The Javascript is loading before the DOM, so it is not ready to attach events to your HTML. This is a pretty common problem related to DOM readiness - your HTML isn't ready to have Javascript applied to it. If you want to wait for the DOM to load, then try using `DOMContentLoaded`. That means you can continue to have your Javascript before your HTML, and encounter no issues. Of course, you can also solve this problem by putting your Javascript **after** your HTML - but this is not always possible.
featured image - DOM Readiness in Javascript
Johnny Simpson HackerNoon profile picture
Johnny Simpson

Johnny Simpson

@smpnjn

Product, Engineering, Web

About @smpnjn
LEARN MORE ABOUT @SMPNJN'S
EXPERTISE AND PLACE ON THE INTERNET.
L O A D I N G
. . . comments & more!

About Author

Johnny Simpson HackerNoon profile picture
Johnny Simpson@smpnjn
Product, Engineering, Web

TOPICS

THIS ARTICLE WAS FEATURED IN...

Permanent on Arweave
Read on Terminal Reader
Read this story in a terminal
 Terminal
Read this story w/o Javascript
Read this story w/o Javascript
 Lite
Coffee-web
Dcs0