Hi,
The notification bar is coded in a way that allows it to be collapsable (aka hidden) which requires checking localStorage to see if the element is closed or not which has to be done with javascript. I could code it to use cookies so you can check cookies with PHP but because all WordPress sites should be cached it’s impossible to make it work correctly.
So the way it works is the notification bar is hidden on page load, the javascript checks the localStorage to see if the element should be visible and if so it displays it by adding a class that removes the hidden CSS.
Because your notification is so large with an image, heading, etc – it’s really obvious when the element loads causing a significant CLS issue (usually it’s not a problem). That said, I checked the plugin code and the script does wait for DOMContentLoaded to remove the hidden class on the notifcation bar. I’m going to update my script so that it checks the localStorage and adds a classname to the HTML tag instead, this way the classname should be added before the notice even renders to ensure it’s visible right away.
That said, I see that on your site you are adding the defer tag to the script which will cause the script to wait for the DOM to load anyway, so you will need to remove that as well:
<script src="https://calnewport.com/wp-content/plugins/easy-notification-bar/assets/js/front.js?ver=1.5" id="easy-notification-bar-js" defer></script>
This is what I see on your site – notice the “defer” attribute.
I will work on the 1.5.1 update with the modified JS.
But you should also preload the image of the book that’s added in the notification bar using code added in the wp_head hook like such:
add_action( 'wp_head', function() {
?>
<link rel="preload" as="image" fetchpriority="high">
<?php
} );
Thank you for bringing this to my attention!
AJ