T
timsamshuijzen
I was wandering what the Javascript/Ajax community think of a rather
unusual
method I am using to develop my new web app. At least I think it is
unusual
because I have not yet found much about this exact method on the
internet.
My web app uses no HTML templates and neither does it use any CSS
files.
It is totally JS/Ajax driven, and there are totally no page fetches/
reloads
(single page interface). My initial page looks a bit like this (the
only html
code in my whole app!):
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title></title>
<script type="text/javascript" src="./js/init.js"></script>
</head>
<body>
</body>
<html>
The init.js is a small script that starts it all up. It does a
XMLHTTPRequest
to a server-side application that only outputs JS code. ALL returned
content
is passed into eval() (I actually do not need to call eval() directly
because
the Content-type is "text/javascript"). The first JS code that is
returned
builds up the whole page, loads some simple libraries, and registers
some
events to observe. From then on, ALL events (except for simple things
like
resizing) are sent to my server application which then outputs more JS
code
that get executed back on the client. For example, a user clicks on a
button,
the request is sent to the server which then returns some JS code to
build
a message dialog and register the corresponding message handlers, and
so on.
Therefore, for every event, the browser "asks" the server what to do,
and the
server tells the browser directly what to do with a snippet of
Javascript.
This has great advantages for me as I now have all my layout, model,
business
logic, etc. in one place. It is like "lazy loading", but an extreme
form.
One might think that it could run quite slow because it connects to
the server
for every user-action, but the returned pieces of code are small
pieces of
code, so the speed is actually quite impressive. This setup results in
an
extremely thin-client. I am very pleased with the first results, and
it makes
the whole development experience much like my original profession:
building
client/server desktop applications.
This is probably a sort of controversial method because I noticed that
there
are mixed opinions about using the eval() function to execute code.
Ofcourse,
the returned code comes from my own server (same origin policy), so no
major
reasons for concern. Another point of criticism is possibly the fact
that I
do not use any (X)HTML templates or CSS files. This aspect is
something I
actually like very much, as I can now build and position all
components with
code, instead of looking all these things up in HTML and CSS files
(great
for website design, but not for desktop-like application development).
So, my questions to you all are:
- what do you think of this strategy?
- If this strategy has already been discussed before, then what is it
called?
(I am calling it AJAJS for the time being (not AJAJ which is JSON
oriented)).
- Where can I find more information about this?
- Are there already existing frameworks based on this?
- Do you think that browsers will continue to support eval(), and not
depreciate
it in the future for security reasons?
unusual
method I am using to develop my new web app. At least I think it is
unusual
because I have not yet found much about this exact method on the
internet.
My web app uses no HTML templates and neither does it use any CSS
files.
It is totally JS/Ajax driven, and there are totally no page fetches/
reloads
(single page interface). My initial page looks a bit like this (the
only html
code in my whole app!):
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title></title>
<script type="text/javascript" src="./js/init.js"></script>
</head>
<body>
</body>
<html>
The init.js is a small script that starts it all up. It does a
XMLHTTPRequest
to a server-side application that only outputs JS code. ALL returned
content
is passed into eval() (I actually do not need to call eval() directly
because
the Content-type is "text/javascript"). The first JS code that is
returned
builds up the whole page, loads some simple libraries, and registers
some
events to observe. From then on, ALL events (except for simple things
like
resizing) are sent to my server application which then outputs more JS
code
that get executed back on the client. For example, a user clicks on a
button,
the request is sent to the server which then returns some JS code to
build
a message dialog and register the corresponding message handlers, and
so on.
Therefore, for every event, the browser "asks" the server what to do,
and the
server tells the browser directly what to do with a snippet of
Javascript.
This has great advantages for me as I now have all my layout, model,
business
logic, etc. in one place. It is like "lazy loading", but an extreme
form.
One might think that it could run quite slow because it connects to
the server
for every user-action, but the returned pieces of code are small
pieces of
code, so the speed is actually quite impressive. This setup results in
an
extremely thin-client. I am very pleased with the first results, and
it makes
the whole development experience much like my original profession:
building
client/server desktop applications.
This is probably a sort of controversial method because I noticed that
there
are mixed opinions about using the eval() function to execute code.
Ofcourse,
the returned code comes from my own server (same origin policy), so no
major
reasons for concern. Another point of criticism is possibly the fact
that I
do not use any (X)HTML templates or CSS files. This aspect is
something I
actually like very much, as I can now build and position all
components with
code, instead of looking all these things up in HTML and CSS files
(great
for website design, but not for desktop-like application development).
So, my questions to you all are:
- what do you think of this strategy?
- If this strategy has already been discussed before, then what is it
called?
(I am calling it AJAJS for the time being (not AJAJ which is JSON
oriented)).
- Where can I find more information about this?
- Are there already existing frameworks based on this?
- Do you think that browsers will continue to support eval(), and not
depreciate
it in the future for security reasons?