Hi Zachary Batastini,
It is not a good option to keep Marketo JS on your server. It may result in non-rendering of the Marketo form. Moreover In some cases, If you keep Marketo JS on your server then that JS can again send a request to Marketo.com to load Form JS. Hence there would be two unnecessary JS request.
You can use Ninja form and on form submission, a lead can be created into the Marketo using REST API. After creating lead through API you need to call associatead API call to track visit webpage activity.
[Denial of Service attack intensifies]
The REST API is not a suitable substitute for Marketo forms. This has been covered many, many times here.
You should read this post: https://blog.teknkl.com/smoothing-embedded-marketo-form-loads/
You cannot successfully load the Forms 2.0 library from your own server, because it's not just the JS library but supporting polyfill and style assets that need to load as well. You can redirect all of that through your CDN to in order to extend the caching period, if you think that would be useful.
Note one of the reasons forms incur network latency is that the form descriptor is reloaded from the origin every time -- that's why, if you make a change in the Form Editor UI, it's reflected immediately on your page. If you're willing to do manual cache invalidation instead, you can embed the descriptor object in a static script block, right on the page. No fetch required.
- I really like the Ninja Forms plugin for wordpress, have successfully set up the webhook to post data to a marketo form BUT when trying to follow guides for associating a lead with a cookie/session to get the page visits and such, nothing appears to work.
This plugin creates a DoS vulnerability against all your integrations (including itself). If you want to use non-Marketo forms, post from the client using the Forms 2.0 JS API. You can load the form embed code asynchronously in this case, as the form rendering doesn't depend on it.