There are two approaches that could handle this, but in general I’d advise against using the multi-page approach with MD5 hashed JS files.
If you really want to do this, then you’ll need to hack something yourself. You can either make a static files storage subclass that updates the paths in the files using a regex, similar to how the current storage updates CSS files. Or, you can load the manifest.json file (generated by ManifestCachedStaticFilesStorage in Django 1.7), and add in the paths at runtime. Both are tricky.
In general, I’d recommend having one giant JS file, with per-page entrypoint methods. This means that you only need to download all the JS for your site once, which in almost all cases will be the fastest approach.
Why will this (probably) be faster? In most sites, the amount of per-page versus library code is tiny. You’ll have 200K of library code, and maybe 10K of your own code, split over say, five pages. Let’s look at how this stacks up:
## Approach 1 - Separate libraries and per-page code.
Load page 1: Download 200K of library and 2K of per-page code = 2 requests.
Load page 2: Download 2K of per-page code = 1 request.
Load page 3: Download 2K of per-page code = 1 request.
# Approach 2 - Bundle everything into one giant JS file.
Load page 1: Download 210K of combined code = 1 request.
Load page 2: Code already downloaded = 0 requests.
Load page 3: Code already downloaded = 0 requests.
Unless your per-page code differences are giant, it’s almost certainly going to be a more complex and slower operation to split it into different modules.
> --
> You received this message because you are subscribed to the Google Groups "django-require discussion and announcements" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to
django-requir...@googlegroups.com.
> For more options, visit
https://groups.google.com/d/optout.