Conditionally loading JS libraries

Check out JS dynamic imports. import() returns a Promise. If you serve both libraryA and libraryB you can dynamically import any of them depending on the logic that you implement.