Automatically Preloading JavaScript Assets in WordPress


(Alex MacArthur) #1

I just wrote on improving WordPress front end performance through automatically preloading JavaScript assets that are enqueued in the footer. Saw some pretty significant results in applications that run several scripts enqueued by multiple different plugins. Hope it helps someone out! Thinking about pluginizing it if there’s enough interest.


(Leland Fiegel) #2

Interesting. Thanks for sharing!


(Hudson Atwell) #3

Thanks and shared!

First time hearing about rel=preload. Sometimes jQuery script is inlined in the dom when jQuery is being loaded in the footer. The rel=preload could keep footer asset loading in play while making sure inline JS has it’s dependencies met.


(Alex MacArthur) #4

Thanks, I appreciate that! Yes, it has some nice advantages over using other tricks like applying an asyn attribute to a script. One downside is that browser support isn’t as great as it could be, but thankfully, there’s no negative consequence to using it for JS anyway. If preloading isn’t supported, it’s just skipped over and nothing breaks.