Skip to content

Commit 58638f4

Browse files
simisonkraftbj
authored andcommitted
Photon: remove wp-dom-ready dependency (#13624)
...this pulls in wp-polyfill which is a lot of kbs for nothing in Photon’s case since it’s ES5.
1 parent cd17208 commit 58638f4

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

class.photon.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1221,8 +1221,8 @@ public function action_wp_enqueue_scripts() {
12211221
'_inc/build/photon/photon.min.js',
12221222
'modules/photon/photon.js'
12231223
),
1224-
array( 'wp-dom-ready' ),
1225-
20190901,
1224+
array(),
1225+
20191001,
12261226
true
12271227
);
12281228
}

modules/photon/photon.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,13 @@
4444
/**
4545
* Check both when page loads, and when IS is triggered.
4646
*/
47-
if ( typeof window !== 'undefined' ) {
48-
window.wp.domReady( restore_dims );
47+
if ( typeof window !== 'undefined' && typeof document !== 'undefined' ) {
48+
// `DOMContentLoaded` may fire before the script has a chance to run
49+
if ( document.readyState === 'loading' ) {
50+
document.addEventListener( 'DOMContentLoaded', restore_dims );
51+
} else {
52+
restore_dims();
53+
}
4954
}
5055

5156
document.body.addEventListener( 'post-load', restore_dims );

0 commit comments

Comments
 (0)