Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove rocket-loader.min.js from Landing Pages #77

Merged
merged 3 commits into from
Sep 10, 2024
Merged

Conversation

n7studios
Copy link
Contributor

Summary

Fixes this reported issue, where a Landing Page setup to redirect, and embedded in WordPress, won't redirect to the thank you page URL.

The redirect not being honored appears to be caused by including rocket-loader.min.js.

The Plugin fetches the landing page HTML, and then iterates through all scripts, checking if each src property is a fully qualified URL. If not (e.g. on landing pages, we find <script src="/cdn-cgi/scripts/7d0fa10a/cloudflare-static/rocket-loader.min.js" data-cf-settings="5756229aeeb7b4c76b79f093-|49" defer></script>), the Plugin will prepend the creator's URL (e.g. <script src="https://cheerful-architect-3237.ck.page/cdn-cgi/scripts/7d0fa10a/cloudflare-static/rocket-loader.min.js" data-cf-settings="c5d46ab73fb7b9b8aae27edf-|49" defer></script>) to ensure it can load the script on a WordPress Page that outputs the landing page HTML (otherwise, the relative path to the script won't work, because the landing page isn't hosted by ConvertKit here).

Removing this script allows the redirect to work, but I'm not understanding why, or whether this script can safely be removed by our WordPress Libraries / Plugins. If someone could let me know, we can then get this fixed.

Testing

  • Updated unit tests to confirm rocket-loader.min.js is removed. The main WordPress Plugin will need its own PR to confirm the same when using this version of the WordPress Libraries.

Checklist

@n7studios n7studios added the bug Something isn't working label Sep 3, 2024
@n7studios n7studios self-assigned this Sep 3, 2024
@n7studios n7studios requested review from a team, noelherrick and jenessawhite and removed request for a team September 3, 2024 03:56
@n7studios n7studios marked this pull request as ready for review September 3, 2024 03:56
Copy link

@noelherrick noelherrick left a comment

Choose a reason for hiding this comment

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

@n7studios Would this remove this rocket-loader for the entire page, including for pages that do not include a CK form? If so, we'll need to dig into this a bit more or perhaps allow the customer to disable it after giving a warning (I don't know if plugins can declare incompatibility with another plugin)

@n7studios
Copy link
Contributor Author

@noelherrick This only removes rocket-loader from the ConvertKit form HTML that's fetched by this library. It doesn't remove anything from any WordPress Page. I'm still uncertain why it needs to be removed to get redirects working, though.

Copy link

@noelherrick noelherrick left a comment

Choose a reason for hiding this comment

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

Ok, cool - yeah, I bet they're trying to be clever but it gets in the way of us doing something clever in our forms JS.

@n7studios n7studios merged commit 07a2fb5 into main Sep 10, 2024
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants