1

So I'm building a javascript library meant to be loaded by external domains. I'm looking for a good way to do auto-versioning for this. Ideally, the external domain should be able to just write <script src="<filename>" type="text/javascript"></script> and somehow have that version correctly.

The best solution I can think of is to have the <filename> point to a page, built using a server-side language, that dynamically includes the right javascript libraries with the right versioning. The problem with this is that it requires the javascript to be dynamically loaded and means that our server will be hit on every load (ie it can't be cached).

Any ideas?

Quentin
  • 914,110
  • 126
  • 1,211
  • 1,335
B T
  • 57,525
  • 34
  • 189
  • 207
  • In addition to the autoversioning problem you probably should look at loading the external script asynchronously to avoid blocking the page [http://friendlybit.com/js/lazy-loading-asyncronous-javascript/] – Jaysen Marais Jan 26 '12 at 04:52

1 Answers1

-1

Refer to this link.

http://blog.sallarp.com/asp-net-automatic-css-javascript-versioning/

This tells us about creating custom control for script tag, link tags(css) and then emits the static contents using the dummy querystring saying ?version=1.2.3

dhinesh
  • 4,676
  • 2
  • 26
  • 44
  • That won't work - the point is that the third parties won't know when to link to the new version. – Quentin Dec 22 '10 at 11:17
  • @David: This is just the approach. The javascript library could have its own version and then that version could always be used in the querystring. – dhinesh Dec 22 '10 at 11:28
  • David's right, this doesn't solved the problem. Also, querystring versioning has a major downside: for some reason there are issues either GZIPing files or caching files that have query strings. That is not an ideal way to version anything. – B T Dec 23 '10 at 20:02