Friday, May 17, 2024
 Popular · Latest · Hot · Upcoming
198
rated 0 times [  200] [ 2]  / answers: 1 / hits: 24571  / 13 Years ago, thu, may 5, 2011, 12:00:00

Is it possible to require an entire folder using requireJS.



For example, I have a behaviors folder with a ton of behavior js files. I'd really like to be able to simply use require(['behaviors/*'], function() {...}); to load everything in that folder rather than having to keep that list up to date. Once compressed and optimized I'd have all those files lump together, but for development it's easier to work with them individually.


More From » requirejs

 Answers
1

javascript in browser has no filesystem access and so it can't scan a directory for files. If you are building your app in a scripting language like php or ruby you could write a script that scans the directory and adds the file names to the require() call.


[#92394] Tuesday, May 3, 2011, 13 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
mira

Total Points: 460
Total Questions: 108
Total Answers: 99

Location: American Samoa
Member since Fri, Aug 26, 2022
2 Years ago
mira questions
;