Hi all, I was wondering if anybody can enlighten me on when it is best to separate javascript code in different script. Let me give you a practical example.
I have a script that I would like to run everytime the page is resized, so I am thinking to use the onresize
event. But I also have some code that I will need to run when the DOM is ready, so I will wrap it inside a $(document).ready(function(){...});
I believe the script that is run onresize doesn't need to be inside a document ready, so is it worth splitting the 2 scripts into 2 separate files?
From here, in general, is it fair to say that the portion of a script that doesn't need to be inside a document ready should be in its own file and the same for the portion that needs to be inside a document ready (even if the one script could potentially call a function in the other file)?
thanks
iamthwee commented: yup +14
Violet_82 89 Posting Whiz in Training
Violet_82 89 Posting Whiz in Training
Violet_82 89 Posting Whiz in Training
Violet_82 89 Posting Whiz in Training
Violet_82 89 Posting Whiz in Training
Violet_82 89 Posting Whiz in Training
Violet_82 89 Posting Whiz in Training
Violet_82 89 Posting Whiz in Training