Skip to content

Conversation

@jaissica12
Copy link
Contributor

@jaissica12 jaissica12 commented Jan 21, 2026

Summary

  • Skip script tag creation when launcher.js is embedded. If window.Rokt.createLauncher already exists, directly call attachLauncher() instead of fetching launcher.js via a new script tag
  • WILL CHANGE THE TARGET BRANCH WHEN MAIN AND DEVELOPMENT ARE IN SYNC

Testing Plan

  • Tested through unit tests

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This pull request optimizes the Rokt launcher initialization by detecting when the launcher.js is already embedded on the page and skipping redundant script tag creation. When window.Rokt.createLauncher exists, the code now calls attachLauncher() directly instead of fetching launcher.js via a new script tag, unless the launcher has already been initialized.

Changes:

  • Modified initialization logic to check for embedded launcher before creating script tags
  • Removed misleading console warning when Rokt is already present
  • Added test coverage for embedded launcher scenarios

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
src/Rokt-Kit.js Updated initForwarder to check if launcher is embedded and call attachLauncher directly, eliminating redundant script loading
test/src/tests.js Updated existing test to force script loading path and added new tests to verify embedded launcher behavior

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

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.


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

@jaissica12 jaissica12 requested a review from guillermot January 28, 2026 21:06
src/Rokt-Kit.js Outdated
return (
window.Rokt &&
typeof window.Rokt.createLauncher === 'function' &&
window.Rokt.currentLauncher === undefined
Copy link
Collaborator

Choose a reason for hiding this comment

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

what's the reason for checking window.Rokt.currentLauncher === undefined?

Is there a scenario where we would ever have window.Rokt, window.Rokt.createLauncher and already have a currentLauncher?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The check already existed in the script.onload callback (line 148), so I kept it for consistency and as a defensive measure. Rather than having different logic in two places, I DRYed it up into the isLauncherEmbedded() helper so both paths use the same validation

@jaissica12 jaissica12 requested a review from rmi22186 January 29, 2026 22:09
@jaissica12 jaissica12 changed the base branch from main to development January 30, 2026 15:30
@jaissica12 jaissica12 merged commit f485b50 into development Feb 3, 2026
9 of 12 checks passed
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.

4 participants