Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I am thinking through how I will use JavaScript for a project which is just in i

ID: 649462 • Letter: I

Question

I am thinking through how I will use JavaScript for a project which is just in its beginning of coding. I am not an expert in JavaScript, but I recognize it as a very important part of the site so I have a few questions:

I often see projects have 1 huge javascript file which handles everything. Is that for the purpose of making things faster?

Is it ok to have javascript functions coded inside html pages? Or is it considered bad design?

Are most people still using jQuery? I have been seeing a proliferation of other .js frameworks. I know Yahoo made one and there are many others. Is jQuery still the defacto standard for most js frameworks needs? (sorry this question is subjective).

How should I approach/test various browser compatibilities? Should I be very concerned about that?

Explanation / Answer

As Mike said, HTTP requests are expensive, and an easy way to minimize them is to minimize the number of files. Usually, there's one "custom" file, and one link to a library, such as jQuery. Ideally, the library is linked from a CDN, such as Google's Javascript library repository, which allows browsers to cache the library once and use it on multiple sites.
Also, like Wyatt said, that "one huge file" is often multiple files at development, which are then combined and minified for production.

It's considered bad design to mix code and markup (as well as markup and styling), regardless of the languages. Separation of these aspects makes maintenance significantly easier for a whole host of reasons. For more information, check out the MVC pattern and why it's so popular.

jQuery is arguably one of the most popular frameworks out there, however, YUI is also quite popular, as is MooTools. There'd be a ton to compare, so I can't go into that here, but Wikipedia has a table of features for them and several other frameworks. I'd personally go with jQuery or MooTools, if for no other reason than they're in active development and updated recently, which suggests they're keeping up with the latest standards and compatibility issues.

Compatibility is something you should definitely be concerned about, especially when doing custom JS stuff. Using a framework like jQuery or MooTools does make this a lot more trivial, though, since they take care of a lot of the base compatibility issues that might arise. You still need to test in your target browsers, though, to make sure there's no unexpected behavior. The simplest way to test the browsers is to open your project in whatever ones you can get a hold of. All the major browsers have developer tools available to them that can help you in all stages of debugging.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote