Separating a javascript admin from another javascript sounds like a good idea.
This performance article is definitely correct. I did not see a situation when caching, since a lot of javascript in one file was not a winner. Even if there is no javascript sharing in the zones, downloading a large file immediately becomes faster than several downloads.
If you have many libraries and javascript files with separate pages, perhaps caching all the libraries makes sense, just make sure that you measure the number of cache accesses for the average user during testing.
There are templates that can be used to minimize download problems. For me, there was an effective method of dividing partitions into modules and only initializing these modules based on function detection.
For example, if I have a UserInfo
module:
!function(ns) { ns.init = function() { ns.setup_login() ns.show_user_info() } ns.setup_login = function() { }
And if I have html on the login page:
<div id="user_login"> <div class="user_info"></div> <div class="login_links"></div> </div>
I can write an initializer like:
$(function() { $("#user_login").each(function() { UserInfo.init() }) })
Without this template, I would write loading setup_login
and show_user_info
separately. This usually allows me to initialize several different modules based on what aspects I find on the page, and if you group these modules according to their dependencies, which usually reduce it even further. (I could do User.init
UserInfo.init
, since I could assume that UserInfo
depends on User
.)
source share