• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Where is JavaScript Processed?

 
Ranch Hand
Posts: 515
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So I'm working through a bug and I'm trying to figure out where JavaScript is processed. Is it processed by the client browser or is it processed by the server before it serves it up. The calls that I'm working w/are basically called when the page loads. They are not called by the onLoad function in the body tag.

Second question - Is there a difference between using the onLoad function in the body tag vs. just putting the call in a <script> tag at the bottom of the page and calling it there?
 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
A JavaScript engine [JavaScript interpreter/JavaScript implementation] interprets JavaScript source code and executes the script at the browser level. There are a few engines out there hence why browsers behave differently.

onload fires when everything is done loading on the page.
Putting a script tag at the end is just firing when it gets to it. The body is not fully built yet, but almost everything is ready to go at that point.

Eric
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It is a much better practice to use onload than to stick a script block at the bottom of the page.
 
Think of how stupid the average person is. And how half of them are stupider than that. But who reads this tiny ad?
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic