I custom coded a dynamic database linked (through asp.net) photo gallery in javascript which manages about 300 images. There is no redundant code, but it is about 500 lines long. Should I be splitting it into different .js files, or is the one .js file with 500 lines okay? Is there a best practice for ensuring that javascript files stay under a certain amount of lines of code?
I custom coded a dynamic database linked (through asp.net) photo gallery in javascript which
Share
The number of lines of codes doesn’t matter. From a speed perspective it’s better to place it in one file, because that reduces the number of trips to the sever, and the browser can cache the file for all future pages that uses it.
It sounds like you haven’t run a minimizer (like YUI Compressor) on the file to shrink the size. That is the next step I would take as it will reduce the file size and reduce the download time.