wrap css/js calls with autov()


ljm42

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
Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.