wxt-dev / wxt-dev/wxt

`injectScript` should wait for script to load

Open
#1,865 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
10.5k
Forks
564
PR merge metrics
No merged PRs in 30d

Description

Feature Request

Currently, injectScript returns immediately after appending a script. It would make sense to wait until "load" event is fired, so the caller knows that the script is injected and ready to use.

Is your feature request related to a bug?

N/A

What are the alternatives?

One alternative is to add a new option to options to enable such behavior. This way it can be opt-in and won't change current behavior.
Another way is to return script from the function and allow users to do whatever they want with the object.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the injectScript entry point and reading how it appends scripts and returns. Compare the proposed load-waiting behavior with the opt-in and returned-script alternatives, then define and verify the chosen API behavior, including when callers can safely use the injected script.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
api, tooling
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.