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
March 26, 2018 at 2:30 pm
#268900
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.