dkuku
Js is not my strongest skill and I can’t find this in the kino examples.
Every time I wan’t to include js it only works for me inside a callback function that I pass to the promise. With one included file it’s fine but with multiple it becomes tricky.
Importing on top of the file does not work with every kind of js file like in the mermaid example.
If I try to import the url that is provided in the importJS in the example below it throws an error in the js.
I tried the same with pev2 package and I have similar problem there.
defmodule VlBlockly do
use Kino.JS
def new(toolbox) do
Kino.JS.new(__MODULE__, toolbox)
end
asset "main.js" do
"""
const blockyRoot = '<div id="blocklyDiv" style="height: 480px; width: 600px;"></div>'
export function init(ctx, toolbox) {
ctx.importJS("https://unpkg.com/blockly/blockly.min.js").then(() => {
load(ctx, toolbox)
})
}
const load = (ctx, toolbox) => {
ctx.root.innerHTML = blockyRoot;
const workspace = Blockly.inject('blocklyDiv', {toolbox: JSON.parse(toolbox)});
}
"""
end
end
toolbox =
%{
contents: [
%{kind: "block", type: "text"},
%{kind: "block", type: "text_print"}
],
kind: "flyoutToolbox"
}
|> Jason.encode!()
VlBlockly.new(toolbox)
Trending in Questions
I having some trouble figuring out if I have set myself too strict of standards for my production server. Currently I can handle 75% of r...
New
Documentation
While reading the Scoped Routes section, I noticed that the documentation currently refers to a problem without explainin...
New
Hello,
I know there is an approach for handling lists that allows for optimized traversal, but I can’t recall the specific method (somet...
New
Hi everyone,
I am toying with the idea of building a “match maker” for giving personal help to people that wants to start coding.
I sta...
New
So my question is quite simple and i have found no conclusive answer on forum, google or AI.
Should we use :erlang.float for Integer to ...
New
I recently noticed that Elixir’s Logger defaults its primary log level to :debug when no :logger, :level application configuration is pre...
New
I’m new to elixir and just tried to install the elixirLS extension for VScode(ium) and it is throwing some errors that I would like help ...
New
Other Trending Topics
Edit: 2026 May 15 - This post is archived.
Mob is alive!!
Main docs: mob v0.7.11 — Documentation
A bit of explanation for the slightly c...
New
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
I am happy to introduce the very α version of the new programming language compiled to BEAM.
Welcome Cure.
It has literally three kille...
New
Hobbes is a low-level distributed database for the Elixir programming language.
Hobbes provides a simple, safe, and scalable storage lay...
New
Hi everyone!
The first release candidate for the Expert language server project is now available!
We’ve published a press release detai...
New
A little off-topic, but I feel like people here have a good head on their shoulders.
I used to be quite good at making software. Was luc...
New
Latest Livebook Threads
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #library
- #deployment
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ai
- #ecto-query
- #elixirconf-us
- #blog-post
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #elixirconf-eu
- #api
- #forms
- #metaprogramming
- #hex











Showing Posts 1 to 5- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
jonatanklosko
@dkuku so the confusion is around importing multiple dependencies with
importJS? You could import the second file inside the callback, but to avoid nesting you can doasync/await. Like this:If you run into any errors, please include those : )
Sidenote, you don’t need to use
Jason, the payload is automatically serialized and deserialized!Yeah, it depends on how the package is distributed. Top-level import works fine for ES modules, but some packages expect to be loaded via
<script>tag, which is exactly whatimportJSdoes.In more complex cases you can also consider using a JS bundler as in a regular JS project.
dkuku
Thanks for the hints
dkuku
@jonatanklosko
I wonder if having a html asset would not make things easier here? Then the scripts can be embedded directly in the html. rit would be easier to mirror the examples from the web. Building the initial root layout could be also simplified.
jonatanklosko
@dkuku there is
Kino.HTMLfor some range of use cases, but most of the time we use the JSinitfunction as an entry point, because it receives data from the Elixir side.adolfont
This thread was very useful.
I was also able to use p5.js (a JavaScript library for creative coding) inside Livebook. In really don’t know if I can do much more than that.
https://twitter.com/adolfont/status/1655554171867627521