Skip to content

Fix Feedex widget never rendering by switching script strategy - #27

Merged
Rian-Fernando merged 1 commit into
mainfrom
fix-feedex-script-strategy
Aug 3, 2026
Merged

Fix Feedex widget never rendering by switching script strategy#27
Rian-Fernando merged 1 commit into
mainfrom
fix-feedex-script-strategy

Conversation

@Rian-Fernando

Copy link
Copy Markdown
Owner

The widget shipped in #26 but no launcher ever appeared on production.

What was ruled out

Everything looked healthy:

  • widget.js200
  • GET /api/v1/widget-config?key=...200, valid config for the NetPost project
  • injected tag carried all nine data-feedex-* attributes, correct key
  • no console errors (the widget fails silently by design)

Yet window.Feedex was undefined and no shadow root existed. Since the config request did go out, the script was clearly executing — so neither the key nor the domain allowlist was at fault.

Isolating it

On the live page, I removed Next's injected tag and appended a plain script element with the same key:

Injection window.Feedex Widget UI
next/script lazyOnload undefined none
plain document.createElement("script") object shadow host created

Same page, same key, same script. The strategy was the problem.

Cause and fix

lazyOnload injects after the window load event has already fired. The widget's eager work still runs — hence the config request — but the part that attaches window.Feedex and renders the launcher hangs off an event that has already passed.

afterInteractive injects during hydration, while that event is still ahead of it.

Worth noting

The Feedex Next.js quickstart recommends lazyOnload, so this is worth fixing in your own docs — anyone following them on App Router will hit the same silent no-op.

The widget shipped but no launcher ever appeared on production. The script was
fetched (200), it read its key and fetched its remote config successfully
(200, valid config for the NetPost project), and the tag carried all nine
data-feedex-* attributes. Despite that, window.Feedex stayed undefined and no
shadow root was created, with no console errors, because the widget fails
silently by design.

Isolated it on the live page: removing Next's injected tag and appending a
plain script element with the same key immediately produced window.Feedex as
an object and a new shadow host. So the script and the key were fine and the
injection strategy was not.

strategy="lazyOnload" injects after the window load event has already fired.
The widget's eager work still runs, which is why the config request went out,
but the part that attaches the global and renders the launcher hangs off an
event that has already passed. afterInteractive injects during hydration and
the widget boots normally.

The Feedex Next.js quickstart recommends lazyOnload, so this is worth
reporting upstream.
@vercel

vercel Bot commented Aug 3, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
netpost Ready Ready Preview Aug 3, 2026 7:45pm

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes the Feedex feedback widget failing to render in production by changing the Next.js Script injection strategy so the widget initializes before its internal “on load” hooks are missed, and updates the project documentation to reflect the rationale.

Changes:

  • Switch Feedex script loading from strategy="lazyOnload" to strategy="afterInteractive" in the root layout so the launcher reliably appears.
  • Expand in-code documentation in layout.tsx explaining why lazyOnload causes a silent no-op for this widget.
  • Update the README “Feedback” section to match the new strategy and document the observed behavior.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
README.md Updates Feedex integration docs to reflect afterInteractive and explain why lazyOnload fails.
frontend/app/layout.tsx Changes next/script strategy to afterInteractive and documents the production behavior/regression cause.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@Rian-Fernando
Rian-Fernando merged commit 71bb0ae into main Aug 3, 2026
9 checks passed
@Rian-Fernando
Rian-Fernando deleted the fix-feedex-script-strategy branch August 3, 2026 19:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants