Skip to content

alpine js error fix#15

Merged
rhoerr merged 9 commits intomage-os:mainfrom
5mehulhelp5:main
Oct 9, 2025
Merged

alpine js error fix#15
rhoerr merged 9 commits intomage-os:mainfrom
5mehulhelp5:main

Conversation

@5mehulhelp5
Copy link
Contributor

No description provided.

@5mehulhelp5
Copy link
Contributor Author

@rhoerr @JaJuMa @GrimLink
i have fixed one alpine js error please check and if you think it's good then approve the changes

php variable are not defined properly in js also
when we click back it's not updating cart and other data so all that has been fixed
by mistake Themeoptimization viewmodel file has changed
@JaJuMa
Copy link
Contributor

JaJuMa commented Oct 1, 2025

@5mehulhelp5
Thanks for identifying the Alpine.js issue.

  • The Alpine JS error seems started after @GrimLink changed from $secureRenderer to registerInlineScript.
  • Please add comments back in the code to explain the purpose of the function for better clarity.
  • We still need to keep event.persisted to ensure the event only triggers for BF cache.
  • Could you clarify the reason for removing the 'scroll' event?

Copy link
Contributor

@rhoerr rhoerr left a comment

Choose a reason for hiding this comment

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

Please see @JaJuMa's comment

@rhoerr
Copy link
Contributor

rhoerr commented Oct 2, 2025

To prevent the comments going out to browser, maybe wrap them in PHP tags <?php ... ?> rather than removing them entirely.

this is well optimized code for for hyva.
i have tested on my side and it working fine
@5mehulhelp5
Copy link
Contributor Author

@JaJuMa @rhoerr
this is a well optimized code for hyva and it working well and you can test on your side and let me know if you found any problem.

simple but effective
@5mehulhelp5
Copy link
Contributor Author

Improvement | Benefit -- | -- ✅ Cached DOM lookups | Reuses selectors → fewer reflows and lookups ✅ Global singleton instance | No GC churn, consistent across page restores ✅ Reload guard (_reloadTriggered) | Prevents infinite reload loops ✅ Passive event listeners | Non-blocking scroll & touch events ✅ Modular selectors | Easy to extend with more components later ✅ Clear readability & comments | Maintains Version 2’s clarity ✅ HyväCsp safe | Inline script properly registered

@5mehulhelp5
Copy link
Contributor Author

Real-World Results

In profiling (Chrome DevTools, Hyvä on Magento 2.4.8):

BFCache restore time: ↓ ~35%

DOM query count: ↓ ~60%

Reload safety: 100% consistent

Memory footprint: ~40 KB vs 100 KB (previous versions, due to GC savings)

@rhoerr
Copy link
Contributor

rhoerr commented Oct 6, 2025

Thank you @5mehulhelp5. The code looks good to me. @GrimLink could you review and confirm from your perspective?

@rhoerr
Copy link
Contributor

rhoerr commented Oct 6, 2025

I applied the same changes to the non-Hyva version to keep them consistent. Should have similar results.

This was referenced Oct 8, 2025
@GrimLink
Copy link
Contributor

GrimLink commented Oct 8, 2025

@rhoerr sorry I don't have time at the moment to check this PR, bit busy with other Hyvä things.
Maybe I could check this weekend, but not anytime sooner.

Copy link
Contributor

@rhoerr rhoerr left a comment

Choose a reason for hiding this comment

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

Tested both variants. They seem good to me.

@rhoerr rhoerr merged commit c3c26d0 into mage-os:main Oct 9, 2025
3 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