Roll20 uses cookies to improve your experience on our site. Cookies enable you to enjoy certain features, social sharing functionality, and tailor message and display ads to your interests on our site and others. They also help us understand how our site is being used. By continuing to use our site, you consent to our use of cookies. Update your cookie preferences .
×
Create a free account

Question about Sheet Workers

Hello again I have one question about the Sheet Workers Is it a requirement to have all the JS in one massive <script> tag or are we allowed to split it in smaller <script> just under (or above I'm not picky) the relevant HTML ?
1623422265
Kraynic
Pro
Sheet Author
They must all be within a single script text/worker tag. <a href="https://wiki.roll20.net/Sheet_Worker_Scripts#Adding_a_Sheetworker" rel="nofollow">https://wiki.roll20.net/Sheet_Worker_Scripts#Adding_a_Sheetworker</a>
1623439262
GiGs
Pro
Sheet Author
API Scripter
A minor clarification: I think it might be possible to use separate script blocks, but for a period of time there was a bug that only one script block in each sheet was recognised. Ever since it's been a strong recommendation to use one script block. It's good practice for a separate reason: sometimes you have functions and constants that you want to use in multiple sheet workers. But each script block is completely isolated from each other, so you have to make copies of any shared data. Finally, when sheet editors work on a sheet, their javascript editing tools often work best if you have one large script block. So even if it's possible, there's no good reason to break up your sheet workers into separate script blocks. It's better to keep them all together.
Kraynic &nbsp;said: They must all be within a single script text/worker tag. GiGs said: So even if it's possible, there's no good reason to break up your sheet workers into separate script blocks. It's better to keep them all together. Thanks for the answers I was just asking because I started working with React (and even before that having multiple smaller .js files was a nice way to stay organised)
1623454698
Andreas J.
Forum Champion
Sheet Author
Translator
sure, you can have source files split up into several smaller ones, makes for easier development and organization, but then compile everything into a single file. Example: <a href="https://github.com/Roll20/roll20-character-sheets/tree/master/GODSEND-Agenda" rel="nofollow">https://github.com/Roll20/roll20-character-sheets/tree/master/GODSEND-Agenda</a>
Thanks I didn't know about PUGjs