DEV Community

Samcorp
Samcorp

Posted on

CSS/JavaScript Changes Not Reflecting in WordPress

Description
Changes to CSS or JavaScript files do not appear on the front end.

Causes
Browser caching.
CDN cache.
Incorrect file versioning.

Solution

  • Clear Browser and CDN Cache.

  • Use Versioning for Enqueued Files:
    Update the file version in functions.php:

wp_enqueue_style('custom-style', get_template_directory_uri() . '/css/style.css', array(), filemtime(get_template_directory() . '/css/style.css'));
wp_enqueue_script('custom-script', get_template_directory_uri() . '/js/script.js', array('jquery'), filemtime(get_template_directory() . '/js/script.js'), true);
Enter fullscreen mode Exit fullscreen mode

WordPress development services to build custom websites that are fast, secure, and easy to manage. From creating themes and plugins to optimizing performance, we ensure your website meets your business needs. Get a professional, user-friendly site that stands out.

Top comments (0)