You can create your own index/index3 html pages (login/main pg respectively) and load script there.This is useful for loading global scripts, like jQuery.
However, for JS specific to individual fields and the like, you can utilize the HTMLSnippet widget in the appstore. It allows you to place HTML and run JS at form-level.
Additionally, you can write your own widgets in JS, which extend the dijit interface. Mendix has a Client API you can utilize via JS. Here's a helpful link for the API.
For widget creation tutorials, check out this.