In my userscripts, I often @require
a self-written javascript library. I'm wondering how much load this generates. Is the library (re-)loaded every time a userscript is executed? Or is it only loaded the first time, and then cached? Would minifying it make a significant difference?
I looked at the tampermonkey docs, but they don't go into detail about this. They only state that the library "is loaded and executed before the script itself starts running".
How important is it to minify this library? Since I make changes to the library fairly often, I would prefer to avoid the extra step of minifying it every time. What are the advantages and disadvantages of minifying such a library?
Also, the precise details of how often a script is checked change. But here's how it usually/is supposed/used to work:
@require
library is fetched and saved to disk (nowadays stored as part of extension data in a LevelDB database).@require
string is changed, the script is refetched.@require
d scripts, with file://
URLs, at every run as an aid to developers. But this stopped working and not sure what the current status is.The point is that nominally, a required file (with an off-machine URL) should be run from disk or cache and be very fast.
So trade-offs:
Don't minimize because:
Do minimize because:
@require
d script has a large install base and hosting server load is a concern.<script>
tags) -- so bandwidth is much more critical. (Not everyone has high-speed connections, etc.)