Re: Dynamic loading of javascript files into web pages
- From: One Dumm Hikk <hikksnotathome@xxxxxxx>
- Date: Sun, 28 Jun 2009 23:11:35 -0700 (PDT)
On Jun 28, 9:57 pm, Jorge <jo...@xxxxxxxxxxxxxxxxx> wrote:
One Dumm Hikk wrote:
On Jun 27, 9:39 am, Jorge <jo...@xxxxxxxxxxxxxxxxx> wrote:
On Jun 27, 10:42 am, Gregor Kofler <use...@xxxxxxxxxxxxxxxx> wrote:
(...)The problem is:
As Jorge already mentioned:http://www.youtube.com/watch?v=52gL93S3usUandthe"degrading script
pattern" - it escapes me where the actual problem is, requesting such a
bizarre "solution".
- Given a script that has not been loaded yet (still loading), -
usually a dynamically inserted one-,
- Find the best way to have some piece of code run asap, immediatly
after the script (above) has loaded and executed.
(note that "onload" is not -usually- available on <script> tags in
most browsers)
That is trivial to do. Again, people try to make this stuff
harder than it has to be. Want a fool proof way to make a script
in an external file execute and know that is has loaded? Search
the archives, I have shown this MANY times and it was even before
many people knew JRs name.
At the end of the external file, place the call to the function
that you want executed.
Yes we do that in e.g. every JSONP response.
> It will NOT get executed until the file
is loaded and it will get called only when the file gets loaded.
Stop making this harder than it has to be. Sheesh people.
That f() must be a global and requires a previous, separate <script>.
Resig's solution requires none of these.
Pure nonsense. It doesn't have to be global nor does it
"require a previous, seperate <script>".
f() can be a property of a single global object and the call
can be made in the same file that you are loading. I know that
to be true because its the way I have been doing it for many
years now. Download a .js file that has data in it with a
function call at the end of the file that deals with the
data in the file. That is how you deal with the issue of
knowing when/if the file is downloaded or not. It is
the ONLY *reliable* way to know that the data file has
downloaded.
Perhaps you should search the c.l.j archives for
"dynamic script insertion" and spend the next two
weeks or so reading the many many threads on this
topic.
On Jun 27, 10:30 am, Jorge <jo...@xxxxxxxxxxxxxxxxx> wrote:
On Jun 27, 3:49 am, One Dumm Hikk <hikksnotath...@xxxxxxx> wrote:
Dynamically loading script files to speed up the loading process?I'm not sure why do you say so, as it's obvious (isn't it ?) that
Garbage.
What it will do, if done properly, is speed up the initial
rendering of the page. But it WON'T speed up load time of the
files and will actually slow it down. The reason it will
actually slow it down is because it has to do more work to
load the files. Whether the file is static coded or dynamically
loaded, the file still has to be downloaded from the server.
Want it to download faster? Make the file physically smaller.
Any other advice is magical hocus-pocus for making it load
faster if everything else is the same.
(...)
latency times add up when the scripts are loaded in series.
I say that because its patently true. Unless you want to try to
convince me that connection speed is determined by how the file
was attempted to be loaded. Again, take a HARD look at the original
script, how it was written, and how it would work. Then let's
discuss what it will or won't do.
<script>s hardcoded in the source .html halt parsing and download in
series, while dynamically inserted ones don't halt parsing and download
in parallel.
And that is precisely what I said. It doesn't change the download time
it
takes, it changes the rendering time to render an initial page so that
you fool the uneducated into thinking the page has finished "loading"
because they see content. Witness mySpace and its abominable use of
AJAX to try to "speed up" the site when in fact its a classic example
of the *wrong way* to speed up a site.
Has John Resig gotten any clue about JS in the last 18 months or so?
If he hasn't, then he still doesn't have a clue.
DM in disguise ?
That question, in and of itself, displays your level of knowledge
of what you are attempting to discuss. Try searching the archives
for the suggested search, read it all, and then get back to me.
Because as it stands now, your question shows that you have made
no effort to research the archives to find out about the subject
you are trying to portray yourself as an expert on.
I am not what I would consider an "expert" on the topic but I simply
have done a TON of research in the last 10 years or so on the topic
and a perusal of the archives would answer many of the questions you
are trying to - incorrectly - answer.
--
Randy Webb
.
- Follow-Ups:
- References:
- Dynamic loading of javascript files into web pages
- From: neilc
- Re: Dynamic loading of javascript files into web pages
- From: Thomas 'PointedEars' Lahn
- Re: Dynamic loading of javascript files into web pages
- From: Jeremy J Starcher
- Re: Dynamic loading of javascript files into web pages
- From: Peter Michaux
- Re: Dynamic loading of javascript files into web pages
- From: One Dumm Hikk
- Re: Dynamic loading of javascript files into web pages
- From: Jorge
- Re: Dynamic loading of javascript files into web pages
- From: One Dumm Hikk
- Re: Dynamic loading of javascript files into web pages
- From: Jorge
- Dynamic loading of javascript files into web pages
- Prev by Date: Re: FAQ Topic - I get an error when trying to access an element by getElementById but I know it is in the document. What is wrong? (2009-06-26)
- Next by Date: Re: FAQ Topic - I get an error when trying to access an element by getElementById but I know it is in the document. What is wrong? (2009-06-26)
- Previous by thread: Re: Dynamic loading of javascript files into web pages
- Next by thread: Re: Dynamic loading of javascript files into web pages
- Index(es):
Relevant Pages
|