How to install and use js scripts? (moments.js)

What I’m trying to do

In general use js scripts in my vault but mainly the moments.js script to make an auto updating link to daily/weekly/monthly note in a homepage (based on My Obsidian Setup (Part 23) — My Homepage | by Nuno Campos | Technology Hits | Medium, view on blocker)

Things I have tried

Copy moments.js code > make into .js file > make folder for scripts > add script to folder (both drag n drop and moving the script to the folder) > add folder to user script folder location in templater (script is detected) > make macro config in quickadd > create macro in quickadd > run on command palette > never ending “no command selected” error.

I’ve tried that on both mobile (android) and desktop (linux), a general guide on how to install js scripts in appreciated, thank you in advance.

Here you can find some examples with a step by step:

Here’s a video installing Zettelizer script:

Also, another script, but here I explain how to add your custom script to a quickadd macro

moment.js is already loaded by Obsidian and exposed as a global function moment. You can access it everywhere you can run js in Obsidian.


Thanks, a fork of zettels is one i wanted to install (now works perfectly), but for moments i now get “format.replace is not a function”. Did the same steps as zettels, didn’t change the code or anything either.

How are yous saying to do so? Can’t find any command to run js or for moments (excluding quickadd attempt that failed).

You can run javascript from dataviewjs scripts, code blocks in Templater templates, user script from QuickAdd, and some more dedicated javascript plugins like CustomJS, Code Emitter, JS Init, JS Engine, just to mention a few (in no particular order).

1 Like

This fixed it, thanks. Sorry for late reply, wanted to make sure it switched days.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.