# How to define pre-compile workloads for Makie figures in a module?

**URL:** https://discourse.julialang.org/t/how-to-define-pre-compile-workloads-for-makie-figures-in-a-module/135683
**Category:** Visualization
**Tags:** precompilation, makie, precompiletools
**Created:** [February 16, 2026, 4:52pm UTC](https://discourse.julialang.org/t/how-to-define-pre-compile-workloads-for-makie-figures-in-a-module/135683 "2026-02-16T16:52:30Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![RoyW](https://avatars.discourse-cdn.com/v4/letter/r/e9bcb4/32.png) [@RoyW](https://discourse.julialang.org/u/RoyW)
#### Post date: [February 16, 2026, 4:52pm UTC](https://discourse.julialang.org/t/how-to-define-pre-compile-workloads-for-makie-figures-in-a-module/135683/1 "2026-02-16T16:52:30Z")

</div>

I modified the interactive button counting example from the official Makie documentation. It has a mouse-hover and button-click interactive events.

May someone please help me with the pre-compilation workload code? I would like to reduce the compilation latency an user would experience when the user mouse-hover over any of the bars (`DataInspector` event) or click on any of the buttons (the `on` event).

My sample code:

```julia-auto
module CounterTutorial

    using GLMakie

    function create_dashboard(initial_count_values::AbstractVector{<:Integer})

        num_buttons = length(initial_count_values)

        fig = Figure()

        ax = Axis(fig[1, 1])
        fig[2, 1] = buttongrid = GridLayout(tellwidth = false)

        counts = Observable(initial_count_values)

        button_labels = [lift(x -> "Count: $(x[i])", counts) for i in eachindex(initial_count_values)]

        buttons = buttongrid[1, 1:num_buttons] = [Button(fig, label = l) for l in button_labels]

        for i in 1:num_buttons
            on(buttons[i].clicks) do _
                counts[][i] += 1
                notify(counts)
            end
        end

        barplot!(counts, color = cgrad(:Spectral)[LinRange(0, 1, num_buttons)])
        ylims!(ax, 0, maximum(initial_count_values) * 2)

        DataInspector()

        return fig
    end

    using PrecompileTools

    @compile_workload begin

        vs_initial = [1, 2, 3]
        fig = CounterTutorial.create_dashboard(vs_initial)

        # Execute the code path for:
        # - the DataInspector event for mouse-hover over a bar
        # - the `on(buttons[i].clicks)` event
    end
end

println("Calling create_dashboard!")
vs_initial = [1, 4, 3, 7, 2]
fig = CounterTutorial.create_dashboard(vs_initial)
display(fig)

```

I’m on `GLMakie v0.13.8`, `PrecompileTools v1.3.3`, `Julia v1.12.5`. Please let me know if there are alternative approaches to reduce the compilation latency for the user for this type of Makie application. I didn’t managed to get `JuliaC v0.3.0` to with this code under my setup.

---

<div class="post-metadata">

### Author: ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://discourse.julialang.org/u/jules)
#### Post date: [February 16, 2026, 7:11pm UTC](https://discourse.julialang.org/t/how-to-define-pre-compile-workloads-for-makie-figures-in-a-module/135683/2 "2026-02-16T19:11:58Z")

</div>

For the buttons I think you could just `notify(b.clicks)` for each to execute the stored functions. For DataInspector I’m not sure, it’s triggered by the mouse hovering over specific pixels. But you can in principle fake mouse interaction by triggering your own events. Check how I did it for the fake interaction videos in the docs: [Makie.jl/docs/fake\_interaction.jl at master · MakieOrg/Makie.jl · GitHub](https://github.com/MakieOrg/Makie.jl/blob/master/docs/fake_interaction.jl#L215)
