The asset_pipeline guide mentions the use of require_tree for JavaScript and style-sheet files to recursively load every file of the respective files types, but doesn’t mention any advantages or disadvantages of doing so. For instance are there any benefits to me having require_tree in my application.js file? In one case it prevents me from manually having to include individual javascript files for various pages. On the other hand theres been many occasions where I forget that I’m using the require_tree directive and accidentally loading libraries more than once.
Are there any performance-related issues involved in loading javascript/stylesheet files for pages that don’t even make use of them (as would be the case in using require_tree)?
If you are using require_tree, there is absolutely no reason to manually require your own files. You shouldn’t do so, but it won’t hurt if you do since Rails is smart enough to not require the same file twice.
However, you should require files that are “vendorized” or in a gem. “require_tree” won’t require those files automatically. It only requires files that are in app/assets/{type}.