themes-wordpress/independent-publisher-2/inc/script-wpcom.js
Sérgio Gomes ac4759d057
Remove jQuery from Independent Publisher 2
Rewrites existing jQuery code as vanila, IE11-compatible ES5.
The only exception is the customizer code, which is only used in
wp-admin.

Sites that are not making use of other jQuery-dependent functionality
should see a nice reduction in the amount of loaded JS.
2021-01-13 16:27:44 +00:00

33 lines
773 B
JavaScript

/**
* script-wpcom.js
*
* Handles toggling of body class name to help WordPress.com custom colors target color changes at different window sizes.
* The Custom Colors plugin does not support media queries.
*/
( function() {
function checkWidth( init ) {
// If browser is resized, check width again
if ( window.innerWidth > 992 ) {
document.body.classList.add( 'tablet-desktop' );
}
else {
if ( ! init ) {
document.body.classList.remove( 'tablet-desktop' );
}
}
}
function init() {
checkWidth( true );
window.addEventListener( 'resize', function() {
checkWidth( false);
} );
}
// After DOM is ready.
if ( document.readyState !== 'loading' ) {
init();
} else {
document.addEventListener( 'DOMContentLoaded', init );
}
} )();