1

Just curious. My thought is that generated files have negligible overhead in terms of performance but I could be mistaken.

Any thoughts on this?

qodeninja
  • 10,062
  • 27
  • 92
  • 146

3 Answers3

3

There is definitely the negligible overhead for generating the script.

The second (that you'd find out as soon as you started development) is that debugging the script becomes infinitely more difficult.

Justin Niessner
  • 229,755
  • 35
  • 391
  • 521
  • i dunno, simple control structures... not too complicated. – qodeninja Nov 13 '09 at 00:06
  • 1
    It doesn't become an issue until you're generating complex scripts. – Justin Niessner Nov 13 '09 at 00:07
  • @Justin: If it ain't complex, it's probably (not always) not needed to be server-side generated. But I do agree there are still many cases why a simple script requires to be generated dynamically at the server-side. – o.k.w Nov 13 '09 at 00:12
  • He's right, debugging becomes a nightmare. There's a reason that RJS for Rails went out of fashion quickly after being introduced. Neat idea, horrible to troubleshoot. – Avdi Nov 13 '09 at 00:25
2

There are two possibilities here.

Firstly you could be speaking of abstractions for CSS and Javascript (eg GWT) that effectively cross-compile one language to another. Hand-coded Javascript will typically be smaller and more efficient but could take considerably longer to create depending on how high a level the abstraction is. Performance of the cross-compiled version? I've heard claims GWT is within 10% of "pure" Javascript performance. I'm not completely convinced of that but it's the right order of magnitude.

Secondly you could be referring to what is still hand coded Javascript or CSS but has some extra stuff thrown on top. CSS variables are a common example. As long as you don't generate them on every request (ie you cache them in some way) then yes the performance is negligible. Even if you do generate them on every request I'm not sure you'd notice the performance impact (on the client side). The server may suffer depending on the complexity of processing and how often the file is requested (which shouldn't be often if it's effectively cached on the client with far futures Expires headers and so on).

cletus
  • 578,732
  • 155
  • 890
  • 933
1

These couple of SO posts will help:

Server Side Javascript: Why?
When and how do you use server side JavaScript?

Community
  • 1
  • 1
o.k.w
  • 24,261
  • 6
  • 60
  • 62