This page is part of a static HTML representation of the TiddlyWiki at https://tiddlywiki.com/

StartupActions

 25th October 2020 at 4:17pm

TiddlyWiki executes any ActionWidgets found in tiddlers with the following system tags during startup:

  • Executed during initial startup:
    • (executed on all platforms)
    • (only executed when running in the browser)
    • (only executed when running under Node.js)
  • Executed after startup rendering:

Initial Startup Actions

The initial startup actions are useful for customising TiddlyWiki according to environmental factors such as the screen size. For example, the following action widgets when placed in a tiddler tagged $:/tags/StartupAction/Browser will cause the sidebar to be hidden by default when the screen width is less than 1000 pixels:

<$reveal type="lt" state="$:/info/browser/screen/width" text="3000">
<$action-setfield $tiddler="$:/state/sidebar" $value="no"/>
</$reveal>

<$reveal type="gteq" state="$:/info/browser/screen/width" text="3000">
<$action-setfield $tiddler="$:/state/sidebar" $value="yes"/>
</$reveal>

Introduced in v5.1.20 This example switches to the language plugin matching the language reported by the browser:

<$action-setfield $tiddler="$:/language" text={{{ [[$:/languages/en-GB]] [plugin-type[language]sort[description]removeprefix[$:/languages/]] +[prefix{$:/info/browser/language}] ~[[en-GB]] +[addprefix[$:/languages/]] }}}/>

Note that global macros are not available within initial startup action tiddlers by default. If you need to access them then you'll need to explicitly include them with an Pragma: \import at the top of the tiddler:

\import [subfilter{$:/core/config/GlobalImportFilter}]

Post-Render Startup Actions

Introduced in v5.1.23 Post-render startup actions occur after the TiddlyWiki user interface has been rendered. This makes it possible to perform actions that depend on the rendered display (such as displaying modals).