This repository was archived by the owner on Sep 19, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +19
-3
lines changed Expand file tree Collapse file tree 2 files changed +19
-3
lines changed Original file line number Diff line number Diff line change 1
1
<script>
2
- window.learnosityCollection = window.learnosityCollection || [];
3
- window.learnosityCollection.push(LearnosityItems.init(<?php echo $ signed_request ; ?> , { errorListener: function(e) { console.log(e); } }));
2
+ // WP can add "defer" flag to <script> inside "wp_enqueue_script" function
3
+ // it might lead to the error that "LearnosityItems" below in undefined
4
+ // to protect against it, we will use "load" global event to secure that all JS assets are loaded before calling any JS code
5
+ window.addEventListener("load", function () {
6
+ window.learnosityCollection = window.learnosityCollection || [];
7
+ window.learnosityCollection.push(LearnosityItems.init(<?php echo $ signed_request ; ?> , {
8
+ errorListener: function (e) {
9
+ console.log(e);
10
+ }
11
+ }));
12
+ });
4
13
</script>
Original file line number Diff line number Diff line change 1
1
<script>
2
+ // WP can add "defer" flag to <script> inside "wp_enqueue_script" function
3
+ // it might lead to the error that "LearnosityReports" below in undefined
4
+ // to protect against it, we will use "load" global event to secure that all JS assets are loaded before calling any JS code
2
5
window.addEventListener("load", function () {
3
6
window.learnosityCollection = window.learnosityCollection || [];
4
- window.learnosityCollection.push(LearnosityReports.init(<?php echo $ signed_request ; ?> , { errorListener: function(e) { console.log(e); } }));
7
+ window.learnosityCollection.push(LearnosityReports.init(<?php echo $ signed_request ; ?> , {
8
+ errorListener: function (e) {
9
+ console.log(e);
10
+ }
11
+ }));
5
12
});
6
13
</script>
You can’t perform that action at this time.
0 commit comments