Jump to content
ljm42

wrap css/js calls with autov()

1 post in this topic Last Reply

Recommended Posts

Hey plugin authors,

 

Please consider wrapping the css/js calls in your plugins with autov(), so they look like this:

  <link type="text/css" rel="stylesheet" href="<?autov('/webGui/styles/jquery.filetree.css')?>">
  <script type="text/javascript" src="<?autov('/webGui/javascript/dynamix.js')?>"></script>

autov() appends the timestamp of the file to the call, so it renders like this:

  <link type="text/css" rel="stylesheet" href="/webGui/styles/jquery.filetree.css?v=1535741906">
  <script type="text/javascript" src="/webGui/javascript/dynamix.js?v=1535741906"></script>

The main benefit is that after an upgrade the css/js links will automatically change, which ensures the browser won't load stale copies of those files.

 

autov() has been in Unraid since the current repository was added to GitHub on Oct 24, 2015:
  https://github.com/limetech/webgui/blame/master/plugins/dynamix/include/Helpers.php 
so unless your plugin targets a *very* old version of Unraid it won't have issues with this.

 

And starting with 6.6.0-rc2, nginx tells the browser to permanently cache all css/js files that have version strings appended this way. This should give a minor speed boost to every page load, since the browser won't have to check and see if the file has been updated:

 

If it helps, here are some examples of the change in the main webgui:

  https://github.com/limetech/webgui/pull/374/files

Edited by ljm42
  • Upvote 2

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now