Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Design A proper way to (lazy) load css & js or silent injection Reply To: A proper way to (lazy) load css & js or silent injection

#268900
Shikkediel
Participant

Without either the async or defer attribute, the script with be synchronous. That’s why it’s being referred to as “blocking” when there’s still page markup to follow.

The approach I use myself it to make the jQuery library async, wait for it to be loaded and then inject the rest of the scripts in a deferred manner once that happens. Come to think of it, I’ll have to check again if that isn’t actually the only correct way. Scripts depending on jQuery might trigger errors otherwise. I’ll see if I can create an example.