Add version number to include javascript files

47 views
Skip to first unread message

Eric

unread,
Nov 28, 2013, 9:56:51 AM11/28/13
to web...@googlegroups.com
Hi,

This nice one-liner is adding a version number to css and js paths:

response.static_version = true

When including files like this:

{{
    response.files.append(URL('static','css/normalize.css'))
}}

With the compression option to true all the files in the sample above will be combined, same with JS files. In some situations we want files to add .js files to the bottom of the page without adding them to the compressed version so we add them like this:

<script src="{{=URL('static','js/example.js')}}"></script>

And let the be placed at the bottom. That works great, but is there also an option to add the version number to path? That would be even better :)

I have the idea that you've created something for it, but I can't find it...

Hope you can help :)

Tnx!

Niphlod

unread,
Nov 28, 2013, 12:12:35 PM11/28/13
to web...@googlegroups.com
nope, there isn't . a PR has been raised for this but has been turned down (for good reason)
If you need static versioning for files not included in response.files .... use URL('static', '_1.2.3/js/example.js')

BTW, let other tools compress and optimize your big chunk of javascript

Eric Christiaanse

unread,
Nov 28, 2013, 1:08:50 PM11/28/13
to
Okay, that's clear reaction and tip, tnx!

I was thinking about the proposed solution, but many times I've found that Web2Py had build in solutions for my 'problems'. That's why I asked :)
Reply all
Reply to author
Forward
0 new messages