Overhead of dynamic forms

Is creating Dynamic Forms on the fly a bad thing? The overhead…

A Web Application and in it lets say I have several Edit Record pages or contact pages, these forms are dynamically created every-time the page is visited(loaded).

I have this form building class, that receives a config array.
This config array comes from parameters I specify or from Database MetaData

I am wondering about the overhead.??

Should I be generating the code into templates instead?

It’s probably negligible, though I expect it depends on how many fields your form has, and how efficient the form-generating code is. And how busy the site is. If it starts to appear to be running slowly, you have the option to change one of your forms to another method and see if it actually makes any difference.

It’s the kind of thing I think about, having come through computing when we were excited to get our first 20Mb hard disk and 286-based PC, but these days I would imagine few others do.

if you take performance seriously, stop guessing, start profiling

1 Like

Not sure how to profile yet. lol
This is a learning project that I am on as a hobby

My answer is - it depends ™ :shifty:

I guess the least impactful might be no “dynamic” at all. Every time a file needs changing it’s “manual” hard coding — IMHO, can be OK for things that don’t change more often than annoys you

The opposite exteme might be a script that bogs out to the point of hanging the browser. Once code is in place it simply needs to be triggered to run — IMHO, good for when things change more often than you care to deal with all the time. Of course you want to not bog or hang.

For example, a CMS may have a database field for the site name. The template(s) may run a query every page and then display the name. Wasteful? Yes, not much perhaps. Indeed, almost assuredly insignificant, but wasteful just the same assuming once a site name is chosen it isn’t likely to change any time soon.

Maybe putting together a script that caches a result instead of running a query unless there’s been an update?

When you run the query in the CLI how fast is it?

Note of caution, even though caching can be a very good solution in case your forms really are slow, it’s not a good solution if they are not slow. Since caching brings some problems of its own. Since caching brings some problems of its own.

1 Like

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.