DEV Community

Cover image for Loading scripts on your webpage

Loading scripts on your webpage

Jochem Stoel on November 08, 2018

I missed my train and have a hour to fill so let's talk about something simple, loading scripts on a webpage. As a bundle A super easy ...
Collapse
 
tofl profile image
Tom F.

You wrote that it is done that way in Vanilla JS :

document.addEventListener('DOMContentLoaded', event => {
// the page has finished loading
})

Isn't this plain JS ?

Collapse
 
glennmen profile image
Glenn Carremans

Vanilla JS is plain JS, some more info: stackoverflow.com/a/20435744/7446162

If you enable all the "modules" the download size is still 0 bytes: vanilla-js.com/
Vanilla JS

Collapse
 
tofl profile image
Tom F.

Haha okay I get it.

I guess the joke couldn't have worked on me because I don't use Javascript libraries

Collapse
 
jochemstoel profile image
Jochem Stoel

So sweet, I never expected that question.

Collapse
 
jochemstoel profile image
Jochem Stoel

Thanks

Collapse
 
stevenbruno profile image
Steven Bruno • Edited

A little more insight into the async and defer strategies - Google's recommendation on plugging in external javascript