Skip to main content
Erwin.Timmerman
Inspiring
February 15, 2022
Answered

Custom .js file not copied to project (RH 2020.6.76)

  • February 15, 2022
  • 3 replies
  • 355 views

I have made a .js file with code to sort a table column (copied from w3schools).

The code resides in my project's contents\assets\scripts\webhelp_scripts.js

The topic that contains the table to be sorted has the line 
<script src="../../../assets/scripts/webhelp_scripts.js"></script>

 

If I preview the topic in Chrome, the script works just fine.

However, if I compile the project, the js file is not copied to the \assets\scripts folder, so the sorting does not work. If I copy the .js file to the output manually, the sorting works again.

 

Do js files need to be in a specific location to be copied to the output?

    This topic has been closed for replies.
    Correct answer Amebr

    If the file is referenced in a topic, it should get included in the generated output. If it's not, it suggests the path isn't quite correct (maybe it has too many ../ or too few?). The reason it might work with preview is there is another copy of the file in the expected location when viewing the source, but it's not actually in the project? Perhaps look at the log file to see if there are any warnings related to the script after you generate.

    3 replies

    Erwin.Timmerman
    Inspiring
    February 16, 2022

    Well, for some reason, the issue sorted itself 🙂

     

    When I now generate the js file *is* copied to the output. Maybe it needed a few extra compiles (with PDF I sometimes get "failed to generate" when the 2nd run goes OK), or maybe I was viewing an old version before regenerating. 

     

    In any case, it works now. Thank you for your input!

    AmebrCommunity ExpertCorrect answer
    Community Expert
    February 15, 2022

    If the file is referenced in a topic, it should get included in the generated output. If it's not, it suggests the path isn't quite correct (maybe it has too many ../ or too few?). The reason it might work with preview is there is another copy of the file in the expected location when viewing the source, but it's not actually in the project? Perhaps look at the log file to see if there are any warnings related to the script after you generate.

    Jeff_Coatsworth
    Community Expert
    Community Expert
    February 15, 2022

    In Classic versions, those would be considered a baggage file - I thought in 2020 they ended up in the Assets area of the project. Are you still running the very first release of RH2020? There's been 7 patches since.

    Erwin.Timmerman
    Inspiring
    February 15, 2022

    My fault, it actually was 2020.6. I have edited the subject line to reflect the correct info.