Apr 11, 2023
0
Level 2
Reduce JS on every page - excluding scripts from vendor.js and loading them dynamically?
Hi there, I have a fairly large website that I am trying to improve the page speed of via google PageSpeed insights. I'm getting recommendations on reducing unused Javascript to increase the load time.
There are several scripts that only run on 1-2 pages, how can I prevent them from being compiled into the vendor.js file, but keep it a separately extracted file that I can load on demand?
I already have versioning implemented and I am using mix.extract to split my vendor.js file into smaller pieces, but when using mix.extract the split scripts still have to be loaded on every page.... how can I separate certain 3rd part packages to only load & run on certain pages?
Please or to participate in this conversation.