noob - where to load javascript once

71 views
Skip to first unread message

Pete Wason

unread,
Mar 3, 2016, 5:39:52 PM3/3/16
to TiddlyWikiDev
Hi, I looked around in the group, but most of the topics are completely beyond my comprehension at this point.

All I want to do is load chance.js when the whole thing loads so that I can use some of its functions in html tiddlers.

I tried editing the whole file and putting in <script src="chance.js" /> in the head section near
<link id="faviconLink" rel="shortcut icon" href="favicon.ico">

which worked - until I had edited something and saved, and that line went away.

What's the right way to do this?

TIA

Pete

Eric Shulman

unread,
Mar 3, 2016, 5:47:09 PM3/3/16
to TiddlyWikiDev
On Thursday, March 3, 2016 at 2:39:52 PM UTC-8, Pete Wason wrote:
All I want to do is load chance.js when the whole thing loads so that I can use some of its functions in html tiddlers.
I tried editing the whole file and putting in <script src="chance.js" /> in the head section near
<link id="faviconLink" rel="shortcut icon" href="favicon.ico">
which worked - until I had edited something and saved, and that line went away.
What's the right way to do this?

Put your <script...> call into a tiddler (any name), and tag that tiddler with $:/tags/RawMarkup

When the document is saved, it will automatically insert the content from tiddlers with that tag directly into the <head> of the document file, so that the script will be invoked the next time you reload.  

As a side note, you should *never* have to hand-edit the TiddlyWiki source file to add functionality.  Most of the time, there are already hooks and other mechanisms for adding customizations to the core code.

enjoy,
-e
Eric Shulman
TiddlyTools / ELS Design Studios
InsideTiddlyWiki: The Missing Manuals 

Pete Wason

unread,
Mar 4, 2016, 9:52:43 AM3/4/16
to TiddlyWikiDev


Thanks, Eric. More info: The tiddler I want to use chance from is a text/html type, with a form in it which shows up in an iframe. After following your directions, the <script..  code is now in the main <head> section of the TW, and it is no longer in the <head> section of the document inside the iframe. Nothing happens when I click a form input button that calls a chance function - not even an error in the console. Further suggestions?

Pete
Reply all
Reply to author
Forward
0 new messages