JavaScript was developed for Netscape to
improve browser experience. Static website no longer exists today due to this
script. For your information, it is not full language programming, but just
some lines in HTML to improve capabilities. The simple way to put JavaScript is
in inline mode. Programming studies explain inline
JavaScript as the most basic. You write code alongside properties in one
line. This means single line of JavaScript consists of value, ID, class, and
anything you need.
More about
Internal and External JavaScript
Inline JavaScript is just beginning of implementation
of this script. The most important matter is how you put it into HTML. Web
developer will write JavaScript into HTML directly. When you save this file,
JavaScript is not separate file but integrated with website. After testing in
browser, the script is able to load alongside HTML itself. Writing script in
this method is called internal JavaScript.
The benefit of this method is no reference. The page is able to load faster. Since
the script is already in browser, you do not worry about failed when executing
command. JavaScript can be typed in head or body of HTML.
It is easy to write simple JavaScript in one
page. However, dynamic website requires complex JavaScript. When the script is
written in HTML, you need more time to finish one page. Moreover, your work
will be tiresome when the page is more than expected. To overcome this problem,
web developer employs external JavaScript.
It is opposite methods to save the work as simple as possible. In this method,
you can write JavaScript separately then save it with extension as reference
for JavaScript file. On HTML page, you just write id, which refers to this
file. When the page is loading, JavaScript will automatically work as long as
user demands its script.
JavaScript get URL is common
application of external method. It is as similar to link, except website
incorporates JavaScript to get URL. How goes this thing work? You can write
JavaScript in external way. Internal is good, but not effective enough for
complex command. JavaScript will automatically load your request when clicking
or hitting certain link.
There are several things regarding external
JavaScript. As mentioned above, you have one file as website with ordinary HTML
and several JavaScript commands in different files. Website cannot work
properly to execute JavaScript when these files are in separate location. This
means your file should be under one name. This also part of url encode.
When to Use Internal and
External JavaScript Code? This question has already answered in
previous paragraph. Internal method is good when the file is simple and no need
to execute more programs. On contrary, you may execute the same program more
than once. Writing again in the same page is not effective. The solution is
external method. However, internal and external are not definite
implementation. Web developer combines both methods to get more efficient and
faster website. You cannot use external for only single line of JavaScript.
JavaScript is not solely script in HTML. You need to consider other parts to
match perfectly.
0 komentar:
Posting Komentar