Skip to content

Commit

Permalink
Photon: remove wp-dom-ready dependency
Browse files Browse the repository at this point in the history
...this pulls in wp-polyfill which is a lot of kbs for nothing in Photon’s case since it’s ES5.
  • Loading branch information
simison committed Oct 2, 2019
1 parent 5321876 commit ac57bae
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
4 changes: 2 additions & 2 deletions class.photon.php
Original file line number Diff line number Diff line change
Expand Up @@ -1221,8 +1221,8 @@ public function action_wp_enqueue_scripts() {
'_inc/build/photon/photon.min.js',
'modules/photon/photon.js'
),
array( 'wp-dom-ready' ),
20190901,
array(),
20191001,
true
);
}
Expand Down
9 changes: 7 additions & 2 deletions modules/photon/photon.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,13 @@
/**
* Check both when page loads, and when IS is triggered.
*/
if ( typeof window !== 'undefined' ) {
window.wp.domReady( restore_dims );
if ( typeof window !== 'undefined' && typeof document !== 'undefined' ) {
// `DOMContentLoaded` may fire before the script has a chance to run
if ( document.readyState === 'loading' ) {
document.addEventListener( 'DOMContentLoaded', restore_dims );
} else {
restore_dims();
}
}

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

0 comments on commit ac57bae

Please sign in to comment.