If i understand the question correctly, you have pdf.js setup as a separate script file.
I suggest that you use vite along with vite-plugin-singlefile to bundle all necessary js into a single html file.