Posted on Leave a comment

Notification Bar Without Plugin 1kb Simple Paste Code

Many of the WordPress plugins for cookies give consent to unnecessary scripts and code, ultimately leading to a decrease in website performance. This results in slower loading times due to the excessive download of scripts, as well as unwanted CSS and JavaScript elements. I have discovered a single line of code that, when implemented, outperforms WordPress plugins.

Employing this code to create notification bars within WordPress is an effective method for making announcements and enhancing user engagement. To achieve this without affecting your site’s performance, follow the tutorial below on crafting a WordPress notification bar without utilizing a plugin.

Here is how it looks:

<style>.note-left{ float: left; padding: 7px 0px;color: #313131;} #cookies-bar{color: #fff; font-family: inherit;background: #f5f5f5;padding: 15px 23px;position: fixed;bottom: 0;left: 0;width: 100%;margin: 0px;visibility: hidden;z-index: 99999;box-sizing: border-box;box-shadow: 0 -7px 19px -9px #000000c9;}.acpt-rgt{padding: 8px 12px;background: #397aff;border-radius: 8px;float: right; cursor: pointer;}</style>

<p id="cookies-bar"><span class="note-left">We use cookies to offer you a better browsing experience</span><span class="acpt-rgt" onclick="acceptCookie(); return false;">Accept cookies</span></p>

<script>function acceptCookie(){ document.cookie="cookiesclick=1; expires=Fri, 26 Dec 2025 12:00:00 UTC;path=/", document.getElementById("cookies-bar").style.visibility="hidden"; return false; } document.cookie.indexOf("cookiesclick")<0&&(document.getElementById("cookies-bar").style.visibility="visible"); </script>

Paste Code:

Below, you’ll find the HTML, CSS, and JavaScript code that you should utilize for the cookie notification bar. To ensure proper placement, follow these steps:

  1. Log in to your WordPress admin panel.
  2. Navigate to “Appearance” and select “Theme Editor.”
  3. Locate and edit the “footer.php” file.

Insert the provided code in the appropriate section as mentioned above.

Now, you can relish a remarkably swift notification bar without the need for a plugin, completely free of resource-intensive scripts or animations. If you found this guide helpful for creating a WordPress Notification Bar without the use of a plugin by simply pasting the provided code, kindly share your feedback in the comments section below.

Leave a Reply