WebsiteBaker Logo
  • *
  • Templates
  • Help
  • Add-ons
  • Download
  • Home
*
Welcome, Guest. Please login or register.

Login with username, password and session length
 

News


WebsiteBaker 2.13.9 R24 is now available!


R.I.P Dietmar (luisehahne) and thank you for all your valuable work for WB
https://forum.websitebaker.org/index.php/topic,32355.0.html


* Support WebsiteBaker

Your donations will help to:

  • Pay for our dedicated server
  • Pay for domain registration
  • and much more!

You can donate by clicking on the button below.


  • Home
  • Help
  • Search
  • Login
  • Register

  • WebsiteBaker Community Forum »
  • WebsiteBaker Support (2.13.x) »
  • General Help & Support »
  • Versioned css and js for modules and standard files
  • Print
Pages: [1]   Go Down

Author Topic: Versioned css and js for modules and standard files  (Read 109 times)

Offline CodeALot

  • Posts: 604
  • Gender: Male
Versioned css and js for modules and standard files
« on: September 29, 2025, 12:49:22 AM »
For my templates, I have made a function that will always look for modified CSS-files so the visitor will always be 'forced' to load the latest version:

Code: [Select]
function css_versioned($filename) {
    $base_path = '/templates/main/css/';
    $filepath  = $_SERVER['DOCUMENT_ROOT'] . $base_path . $filename;
    return file_exists($filepath)
        ? $base_path . $filename . '?v=' . filemtime($filepath)
        : $base_path . $filename;
}

The CSS files in that directory will then be called like for example:
Code: [Select]
<link rel="stylesheet" href="<?php echo css_versioned(&#39;basics.css&#39;); ?>" media="all" />
It would be nice if WB did that by default for any CSS and JS file it has to load, thus bypassing stubborn caches on the visitor's devices.
Logged

Offline sternchen8875

  • Global Moderator
  • *****
  • Posts: 647
Re: Versioned css and js for modules and standard files
« Reply #1 on: September 29, 2025, 12:14:31 PM »
aus meiner Sicht eine gute Idee und längst Standard in den meisten CMS. Für WebsiteBaker wird die Integration allerdings etwas umfangreicher, muß man doch die ganzen Funktionen mit einbeziehen, z.b. register_modfiles.. ..

In my opinion, this is a good idea and has long been standard in most CMSs. However, for WebsiteBaker, the integration becomes a bit more complex, as you have to include all the functions, e.g., register_modfiles.. ..
Logged

  • Print
Pages: [1]   Go Up
  • WebsiteBaker Community Forum »
  • WebsiteBaker Support (2.13.x) »
  • General Help & Support »
  • Versioned css and js for modules and standard files
 

  • SMF 2.0.19 | SMF © 2017, Simple Machines
  • XHTML
  • RSS
  • WAP2