3 ms·
Put your script tags at the bottom of the html page so that when the JavaScript is executed all the dom elements on the page can be referenced. Either that or b
by darepublic 5y ago
Put your script tags at the bottom of the html page so that when the JavaScript is executed all the dom elements on the page can be referenced. Either that or bootstrap in a window onload callback. I remember picking up and being in awe of secrets of the JavaScript ninja
- kristopolous 5y agoHere's an even bigger secret, if you're doing server-side rendering, putting things on top might actually be better. You're maybe parallelizing things. As the client is downloading and interpreting the css and JavaScript, the server is doing database calls and rendering the HTML. So you actually are doing things on the server side when you're "blocking"on the client. You didn't get this for free. You had to worry about buffers, flushing, and plenty of testing. I don't know if you can still squeak an actual speed up with this technique (there's many attributes you can use to customize things these days) but I used to use it all the time back in the days of platter drives.