☰Read-only archive⌕
Looking for help with Bokeh?

This is a read-only archive. Ask questions and join the conversation on GitHub.

Visit Community Support on GitHub →
Archived discussions · Captured October 28, 2026

Importing functions from JavaScript file inside CustomJS

Community Supportcustomjs
d-que
d-que

Hello everybody,

I am currently writing a bokeh application where I use a bunch of CustomJS as callbacks. In these call-backs I use a bunch of the same functions. So I would like to save them in a js and I would like to import them into my callbacks.

So what I do is

import { a } from './b.js'

And I receive the following output in my JS console in the browser:

SyntaxError: Unexpected token '{'. import call expects exactly one argument.

I am not quite sure why, and how do I fix it?

Many thanks in advance,
Daniel

⌁   Link to post
p-himik
p-himik

JS import/require functionality is a constantly changing mess with different support on different platforms, and I would strongly advise against attempting to use it in a code that’s not going through any compilation step.

The simplest option in your case is to create a global JS object in b.js and use that object and its methods in all relevant CustomJS code.

⌁   Link to post

End of archived discussion · Replies are disabled