u/Ashblowsup

Code works if in many files, but doesn't work in one?

Code works if in many files, but doesn't work in one?

I need help! This is a website for a university project.

I had two files: style.js that's needed in every page, and accounts.js that's for a specific page related to accounts. Everything worked properly.

My professor then said we needed to put everything in one file. Easy, i copied everything from accounts.js into style.js and erased the former from everywhere. Tested it: a number of functions at the end just don't work anymore. It's not all of the accounts.js content, just the last ones.

Before that's mentioned: the code is still flawless, there's no bugs and no issues. I spent three hours crashing out and making sure the problem wasn't me.

I then found this comment:

> I don't believe that to be true - a monolithic js file will take longer to download, and being monolithic there's risk that the page is using 25% of the js on it (or less). – user OMG Ponies

Is this really a thing? It seems like the only explanation, but I didn't find any actual source that confirms this.

Either way, is there any solution? Something that'll let me use a single file without issues?

u/Ashblowsup — 7 days ago