Skip to content

webworkers - initial startup helper #207

@Neon22

Description

@Neon22

New docs are looking great. 👍
Was looking through webworkers and thought you might want to add a starter function which might be used when the page starts up to pre-initialise the workers so they are ready sooner.

I took this from a prior code version so it probably needs some refining, updating to 2026.1.1, and to be in a function
but something like this could be useful to add

# start workers but no handles to use and have to wait - so use ltk.schedule instead
for el in window.document.querySelectorAll("[type='py'][worker][name]"):
    print("found",el, el.id)
    print(workers, workers.id, workers.name)
    el.onload(ltk.proxy(lambda e: print("loaded",e)))
    print(dir(el))
    await workers[el.getAttribute('name')]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions