I have a page which has many event handlers. The code now reached 1000+ lines of codes and I’m beginning to have difficulty reading the codes. I’m now planning to separate the codes to different files. My question is, is there any disadvantages in separating JS codes into different files?
Share
disdvantages?
another HTTP request. developers advise that files be compressed and be in as few files as possible for optimization. the less files you request, the faster (since there is less round trips)
if you use a text-editor with an auto-complete, some of these editors won’t pick-up the stuff from the other file for auto-complete. this can be a problem if you don’t memoize the functions you have.
if one of these inter-dependent files failed to load, your app will break.