if(document.getElementById("resume") !== null) {
  PDFObject.embed("/static/gen/resume.pdf", "#resume");
}

if(document.getElementById("resume") !== null) {
  $(() => {
    PDFObject.embed("/static/gen/resume.pdf", "#resume");
  });
}

Make sure pdf is loaded at the correct time