Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Use filemtime() to version custom styles & scripts #77

Closed
wants to merge 1 commit into from

3 participants

Ashfame Konstantin Kovshenin Ian Stewart
Ashfame

This helps in pushing changes to users who still have an unexpired cache in use.

Ashfame ashfame use filemtime() to version custom styles & scripts so that changes ca…
…n be pushed to users who still have an unexpired cache in use
52d8a3c
Konstantin Kovshenin
Owner

I have mixed feelings about this. I think that it's a good idea when working with large projects, which you deploy on a regular basis. However, when shipping a theme as a product, you'll be using a different version with every release. It makes sense to use that version, or a date (which _s currently does) to bust caches, which is also probably faster because it doesn't touch the filesystem.

Ashfame

However, when shipping a theme as a product, you'll be using a different version with every release.

True if a developer is building a theme for release, think about custom themes!

I understand your concern about performance that it will touch the filesystem, but from PHP manual I am not sure how well its cache play:

Note: The results of this function are cached. See clearstatcache() for more details.

And upon looking up, I found this article from _ck_ in which she mentions its terrible in performance & totally sucks on NFS storage hosts, not sure where its cache go here. I will leave it on you guys to decide.

Ian Stewart
Owner

This feels out of scope for the _s project (though it'd be great if it made it's way into some forks).

Ian Stewart ianstewart closed this
Ashfame ashfame deleted the branch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Sep 9, 2012
  1. Ashfame

    use filemtime() to version custom styles & scripts so that changes ca…

    ashfame authored
    …n be pushed to users who still have an unexpired cache in use
This page is out of date. Refresh to see the latest.
Showing with 3 additions and 3 deletions.
  1. +3 −3 functions.php
6 functions.php
View
@@ -100,16 +100,16 @@ function _s_widgets_init() {
* Enqueue scripts and styles
*/
function _s_scripts() {
- wp_enqueue_style( 'style', get_stylesheet_uri() );
+ wp_enqueue_style( 'style', get_stylesheet_uri(), array(), filemtime( dirname( __FILE__ ) . '/style.css' ) );
- wp_enqueue_script( 'small-menu', get_template_directory_uri() . '/js/small-menu.js', array( 'jquery' ), '20120206', true );
+ wp_enqueue_script( 'small-menu', get_template_directory_uri() . '/js/small-menu.js', array( 'jquery' ), filemtime( dirname( __FILE__ ) . '/js/small-menu.js' ), true );
if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
wp_enqueue_script( 'comment-reply' );
}
if ( is_singular() && wp_attachment_is_image() ) {
- wp_enqueue_script( 'keyboard-image-navigation', get_template_directory_uri() . '/js/keyboard-image-navigation.js', array( 'jquery' ), '20120202' );
+ wp_enqueue_script( 'keyboard-image-navigation', get_template_directory_uri() . '/js/keyboard-image-navigation.js', array( 'jquery' ), filemtime( dirname( __FILE__ ) . '/js/keyboard-image-navigation.js' ) );
}
}
add_action( 'wp_enqueue_scripts', '_s_scripts' );
Something went wrong with that request. Please try again.