-
Notifications
You must be signed in to change notification settings - Fork 34
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
POC: Playing around with defer / sync WP strategies #2273
Draft
GP-Dan-Tovbein
wants to merge
1
commit into
main
Choose a base branch
from
experiment/async-defer-wp-strategies
base: main
Could not load branches
Branch not found: {{ refName }}
Could not load tags
Nothing to show
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
planet-4
added a commit
to greenpeace/planet4-test-sinope
that referenced
this pull request
Apr 29, 2024
/unhold 3bbff2d7-80ab-450e-819b-e05dce83e97f
Test instance is ready 🚀🌑 sinope | admin | blocks report | CircleCI | composer-local.json ⌚ 2024.05.08 12:09:48 |
0f44f51
to
9103230
Compare
planet-4
added a commit
to greenpeace/planet4-test-sinope
that referenced
this pull request
May 8, 2024
/unhold 355987ba-579c-4c32-bc55-f44be163e89d
planet-4
added a commit
to greenpeace/planet4-test-sinope
that referenced
this pull request
May 8, 2024
/unhold c6a65664-3e86-42a5-ac8b-251e69bee545
9103230
to
232869e
Compare
planet-4
added a commit
to greenpeace/planet4-test-sinope
that referenced
this pull request
May 8, 2024
/unhold ff409669-247a-4b68-b3ac-6d8ed5d751ea
232869e
to
f0346e2
Compare
- This is a POC
f0346e2
to
7a26018
Compare
planet-4
added a commit
to greenpeace/planet4-test-sinope
that referenced
this pull request
May 8, 2024
/unhold 9dbe7c4c-1c43-475c-89dd-f772f409f115
planet-4
added a commit
to greenpeace/planet4-test-sinope
that referenced
this pull request
May 8, 2024
/unhold 54f5f1e8-5112-4379-9db2-d9a4c7786713
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Taken from here.
Demo page: https://www-dev.greenpeace.org/test-sinope/get-informed/
Description
As a part of an experiment, I've tested the functionality of defer/sync WordPress strategies by registering scripts.
According to the official Mozilla documentation:
Deferred scripts
Scripts marked for deferred execution — via the defer script attribute — are only executed once the DOM tree has fully loaded (but before the DOMContentLoaded and window load events). Deferred scripts are executed in the same order they were printed/added in the DOM, unlike asynchronous scripts.
Asynchronous scripts
Scripts marked for asynchronous execution — via the async script attribute — are executed as soon as they are loaded by the browser. Asynchronous scripts do not have a guaranteed execution order, as script B (although added to the DOM after script A) may execute first given that it may complete loading prior to script A. Such scripts may execute either before the DOM has been fully constructed or after the DOMContentLoaded event.
Potential ideas for solutions
Testing
Regular 2G
, also test withWi-Fi
async
element is not working always as expectedConclusion
Of course
defer
is the best approach for loading JS scripts since we're ensure that we're able to interact with added into a DOM since it's been fully loaded. However, for scripts that are independent of other scripts, such as tracking scripts,async
is the best approach