Skip to main content

Preview is not working in content explorer with RequireJS?

Preview is not working in content explorer with RequireJS?

I am trying to preview an uploaded document in Content Explorer but using RequireJS in my project. When I remove the RequireJS library the preview works fine moreover when I load RequireJS the preview shows below error:


Cannot read properties of undefined (reading ‘GlobalWorkerOptions’)


Can we preview an uploaded document with RequireJS loaded on the same page?


Did this topic help you find an answer to your question?

7 replies

rbarbosa Box
  • Developer Advocate
  • 553 replies
  • August 3, 2023

Hi @amikumar36 , welcome to the forum.


I’m not sure about RequireJS.


However the previewer loads a bunch of 3rd party libraries when it tries preview a document. Typically each file type does have it’s own previewer.


Check the browser console to see if it is trying to load something that it can’t find.


Also try with pure simple text document and see if there is any difference.


Hope this helps


Cheers


  • Author
  • New Participant
  • 3 replies
  • August 3, 2023

Here is an example codepen in which several files are opening like .txt, .jpg while cannot preview some extensions:



Also console shows no error, all dependency library files are loaded properly in Developer Tool > Network tab.


rbarbosa Box
  • Developer Advocate
  • 553 replies
  • August 4, 2023

Hi @amikumar36


Doing a test for .PDF’s, it is definitely missing the pdf viewer worker process.


Let’s compare both options:


Without Require.js, previewing the “book sample.pdf”, we can see that an extra script is loaded.



This does not happen with the Require.js:



Somehow require.js is preventing that extra script from being loaded.


  • Author
  • New Participant
  • 3 replies
  • August 6, 2023

Hi @rbarbosa,


Yes I definitely observed that.


Is there any possible solution to rectify this issue as I have RequireJS included in my application to load required JS files for each module. It is nearly impossible for me to remove RequireJS from my application as lot of modules are dependent on it.


I appreciate your help and also thanks for your response!


rbarbosa Box
  • Developer Advocate
  • 553 replies
  • August 8, 2023

Hi @amikumar36 ,


I’ll ask my internal folks, see what they have to say, but this might take a bit of time.


On your side, and since I’m not familiar with requireJs, is their community aware of such odd behavior?


Cheers


  • Author
  • New Participant
  • 3 replies
  • August 10, 2023

Hi @rbarbosa,


There is no open/closed issue reported on RequireJS Github repository regarding this scenario as per my knowledge. I suspect it has something to do with the scripts getting loaded for PDF preview. The pdfjsLib and pdfjsViewer properties are resolving to an undefined value. Also I am not able to control the preview.js, pdf.min.js, pdf_viewer.min.js and exif.min.js as these JS files are loaded from Box CdnJS domain (http://cdn01.boxcdn.net/).






It would be of great help if you could help me connect with someone from the developer/technology team.


Thanks


rbarbosa Box
  • Developer Advocate
  • 553 replies
  • August 10, 2023

Yes, that pdf service worker is not getting loaded and registered.


Is there no RequireJS documentation related to when loaded scripts load other scripts?


Something like cascade loading?


Also, I’ve pinged the team, let’s see what they have to say, but it might take a while.


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings