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

Update DelayJS to v2 #7092

Open
MathieuLamiot opened this issue Nov 6, 2024 · 20 comments · May be fixed by #7093
Open

Update DelayJS to v2 #7092

MathieuLamiot opened this issue Nov 6, 2024 · 20 comments · May be fixed by #7093

Comments

@MathieuLamiot
Copy link
Contributor

MathieuLamiot commented Nov 6, 2024

DelayJS v2 must be released on WP Rocket.
The "v2" is currently available on the "v2" branch of the delay JS repo.

Here is the process to automatically update WP Rocket with a DelayJS release: https://www.notion.so/wpmedia/Maintaining-JavaScript-files-98e4112922d540da93e2536866e36fd8?pvs=4#95bb73a9447745228d1c6376e5ad3732

@MathieuLamiot MathieuLamiot added this to the 3.17.3 milestone Nov 6, 2024
@wordpressfan
Copy link
Contributor

I found this PR to merge v2 into develop then we can merge develop into main and release from main but I can see some conflicts, let me check if we can resolve the conflicts from our side or we will need to check with Gael.

@MathieuLamiot
Copy link
Contributor Author

@wordpressfan
Copy link
Contributor

Awesome, so we will ignore conflicts and keep the v2 changes.

@jeawhanlee jeawhanlee self-assigned this Nov 6, 2024
@jeawhanlee jeawhanlee linked a pull request Nov 6, 2024 that will close this issue
@Mai-Saad Mai-Saad self-assigned this Nov 7, 2024
@Mai-Saad
Copy link
Contributor

Mai-Saad commented Nov 8, 2024

@Mai-Saad
Copy link
Contributor

Mai-Saad commented Nov 12, 2024

Regression list

non-regression

@piotrbak
Copy link
Contributor

CC @gmetais

@piotrbak piotrbak removed this from the 3.17.3 milestone Nov 12, 2024
@gmetais
Copy link

gmetais commented Nov 16, 2024

Hi @Mai-Saad,

Could you please describe this issue a bit more?

open page from saved tab loads all script without further interaction (even on 3.17.2.1 of wpr, so maybe browser changes is a factor)
https://wpmediaqa.testrail.io/index.php?/tests/view/44269&group_by=cases:section_id&group_id=4884&group_order=asc

What is a saved tab? Is it related to the fact that DelayJS intentionally loads scripts when the page visibility is hidden?

@Mai-Saad
Copy link
Contributor

@gmetais Here is a video about the saved tab (usually scripts aren't delayed there)
saved pages.zip

@piotrbak
Copy link
Contributor

@gmetais Were you able to take a look at this?

@gmetais
Copy link

gmetais commented Nov 27, 2024

@piotrbak Not yet, I will investigate deeper all the issues reported above this Friday.

(As far as I see, none of them look hard to solve. I'm confident for the moment. 🤞)

@piotrbak piotrbak added this to the 3.17.4 milestone Nov 28, 2024
@gmetais
Copy link

gmetais commented Nov 29, 2024

Hi @Mai-Saad,

A fix for

clicking links on FF will load scripts before doing further interaction (using tab to open link is fine) https://wpmediaqa.testrail.io/index.php?/tests/view/44270&group_by=cases:section_id&group_id=4884&group_order=asc

was merged into DelayJS main branch (see PR https://github.com/wp-media/delay-javascript-loading/pull/137/)

@gmetais
Copy link

gmetais commented Nov 29, 2024

@Mai-Saad,

Also please confirm it fixes this:

clicking the link, we sometimes will see nothing is delayed on chrome/FF https://wp-media.slack.com/archives/CUT7FLHF1/p1731051322877729?thread_ts=1729184313.104719&cid=CUT7FLHF1

@gmetais
Copy link

gmetais commented Nov 29, 2024

Regarding

double tap needed for menu to open with certain template https://wp-media.slack.com/archives/CUT7FLHF1/p1731402244073589?thread_ts=1729184313.104719&cid=CUT7FLHF1

I have contacted Hanna in private to provide a testing env.

@gmetais
Copy link

gmetais commented Nov 29, 2024

@gmetais Here is a video about the saved tab (usually scripts aren't delayed there) saved pages.zip

@Mai-Saad,

DelayJS is currently disabled on the page URL in your video. I've tried with some other pages but couldn't reproduce. I'd be interested in having the environment set up fine, for me to investigate the issue.

@Mai-Saad
Copy link
Contributor

Mai-Saad commented Dec 5, 2024

I have contacted Hanna in private to provide a testing env.

@gmetais Any updates about this one? 🙏

@gmetais
Copy link

gmetais commented Dec 9, 2024

Hi @Mai-Saad,
I'm able to reproduce and I'm investigating, but this one is not an easy bug.

@gmetais
Copy link

gmetais commented Dec 9, 2024

@Mai-Saad, @hanna-meda, @piotrbak,

I have a fix for the issue "double tap needed for menu to open with certain template", I pushed it on the following branch: https://github.com/wp-media/delay-javascript-loading/tree/fix-ios-click

Some quick information related to this bug. Safari has a really strange behavior that seems to prevent the first click event from being fired. A touchstart event is fired, a touchend event too, but no click. For the moment, I don't understand why it works on some pages and not the others.

The fix I found is as weird as the bug itself. Adding an addEventListener('click', function() {}) to the touchstart targeted element, solves the issue, even with an empty callback. At least it works on an iOS 15.8 iPhone.

I note that some developers had already found some similarly strange fixes for the iOS double click issue:

  • here with an empty callback,
  • here with an algorithm that triggers a click if a touchstart and a touchend are detected.

I will try to find the deeper reason for this bug, but in the meanwhile I think that the version published on the above branch is a good candidate for production (the change is low-risky). Could you please test on your side?

@hanna-meda
Copy link
Contributor

hanna-meda commented Dec 10, 2024

@gmetais, thank you once again. This is indeed a capricious bug! Below are the testing results:

Tested on BrowserStack (real devices):
• iPhone 12 Pro (iOS 18): Working most of the time.
• iPhone 15 (iOS 17): Works every other try.
• iPhone 14 Pro (iOS 16): Worked on the first try, but failed in over 10 subsequent attempts.
• iPhone 12 (iOS 15): Working occasionally.

Tested on personal device:
• iPhone SE (2nd gen, iOS 18.1.1): Works intermittently.

Conclusion:
Behavior has improved but is not 100% reliable.

[Later edit]
I double-checked the issue on djs version 1.2.6 (current trunk) across all the above devices and it is working consistently (10/10).
@gmetais We need to ensure this isssue is addressed to prevent introducing a regression.
cc @Mai-Saad, @piotrbak

@gmetais
Copy link

gmetais commented Dec 13, 2024

Thanks a lot @hanna-meda,

I still don't understand which change in DelayJS v2 introduced this regression, but it definitely looks like our old double click issue.

I've started working on a fix based on the idea here #3142 (comment), but with additional securities to prevent clicks being triggered twice on websites that don't experience the bug. I will finish in January.

@piotrbak piotrbak removed this from the 3.17.4 milestone Dec 17, 2024
@gmetais
Copy link

gmetais commented Jan 6, 2025

Hi @hanna-meda,

I've updated the same branch (https://github.com/wp-media/delay-javascript-loading/tree/fix-ios-click) with a new approach for the fix and it is working fine on my test page and my test device. Do you mind making a new round of tests with the updated code please?

Cc. @Mai-Saad @piotrbak

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 a pull request may close this issue.

7 participants