Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,150,686 members, 7,809,591 topics. Date: Friday, 26 April 2024 at 11:44 AM

Which Is Better Inline Javascript Or External Javascript - Programming - Nairaland

Nairaland Forum / Science/Technology / Programming / Which Is Better Inline Javascript Or External Javascript (1666 Views)

Were Can I Download Free Video Tutorials On Javascript Or Ruby / Were Can I Download Free Video Tutorials On Javascript Or Ruby / My Web Development Consultancy Thread(html, CSS, Javascript, Jquery, ASP.NET) (2) (3) (4)

(1) (Reply) (Go Down)

Which Is Better Inline Javascript Or External Javascript by Nobody: 2:45pm On Jan 26, 2016
programmers in the house am baffled with this, which place is better for the javascript code to be placed, inline or external, because there are some code working in inline and it not working in external.


help an upcoming programmer
Re: Which Is Better Inline Javascript Or External Javascript by Nobody: 3:06pm On Jan 26, 2016
It is impossible that some codes work inline and not external.
All javaScript codes can work properly inline or external. But your usage matters, you might have made a mistake somewhere.
Re: Which Is Better Inline Javascript Or External Javascript by Nobody: 3:14pm On Jan 26, 2016
dhtml18:
It is impossible that some codes work inline and not external.
All javaScript codes can work properly inline or external. But your usage matters, you might have made a mistake somewhere.


Try this:
In the html file type <p id="text">some text</p>

Then go to the external JavaScript and type this

alert(document.getElementById("text"wink.innerHTML);
Re: Which Is Better Inline Javascript Or External Javascript by Nobody: 4:43pm On Jan 26, 2016
Provide a full sample code of what you are saying, you can post it on pastebin.com for example and share it here.
Re: Which Is Better Inline Javascript Or External Javascript by sinequanon: 7:39pm On Jan 26, 2016
nunamyeong:



Try this:
In the html file type <p id="text">some text</p>

Then go to the external JavaScript and type this

alert(document.getElementById("text"wink.innerHTML);

Works fine.
Re: Which Is Better Inline Javascript Or External Javascript by Nobody: 8:10pm On Jan 26, 2016
sinequanon:

Works fine.

may be it because of the sublime text am using
Re: Which Is Better Inline Javascript Or External Javascript by sinequanon: 8:18pm On Jan 26, 2016
nunamyeong:



may be it because of the sublime text am using

Probably not. I can guess what may be wrong.

Your OP needs to contain a bit more information. wink

Don't be lazy. Folks whom you are asking to help you may not be inclined to work harder than you. wink wink
Re: Which Is Better Inline Javascript Or External Javascript by Nobody: 8:54pm On Jan 26, 2016
Na wa o
Re: Which Is Better Inline Javascript Or External Javascript by Standing5(m): 10:07pm On Jan 26, 2016
dhtml18:
It is impossible that some codes work inline and not external.
All javaScript codes can work properly inline or external. But your usage matters, you might have made a mistake somewhere.
Inline is better. When you use external, the user browser is forced make one extra http request for that file. In case u are not aware, it is possible to inline some assets like images in binary format. It may make the code less readable but more efficient in terms of speed of page load. In other words, if you can bare the pain of reading and editing the code, end users benefit.
Re: Which Is Better Inline Javascript Or External Javascript by Nobody: 11:16pm On Jan 26, 2016
sinequanon:


Probably not. I can guess what may be wrong.

Your OP needs to contain a bit more information. wink

Don't be lazy. Folks whom you are asking to help you may not be inclined to work harder than you. wink wink


bro. have gone over it again, and have found solution to it.

thanks
Re: Which Is Better Inline Javascript Or External Javascript by sinequanon: 11:47pm On Jan 26, 2016
nunamyeong:



bro. have gone over it again, and have found solution to it.

thanks

That's good.

The more effort you put in, the easier it is to remember in the long term.

Answers on a plate are a false economy in effort.

One ironic thing, though...

Your OP says, "help an upcoming programmer".

What goes around comes around.

Why not spend a little time helping upcoming programmers like yourself, by explaining what you did?

smiley
Re: Which Is Better Inline Javascript Or External Javascript by Nobody: 5:26am On Jan 27, 2016
nunamyeong:



bro. have gone over it again, and have found solution to it.

thanks
And will not share the solution with other learners and curious minds? Never again come to this board with your problems, i have marked your username and will never respond to your post.
Re: Which Is Better Inline Javascript Or External Javascript by Nobody: 7:20am On Jan 27, 2016
dhtml18:

And will not share the solution with other learners and curious minds? Never again come to this board with your problems, i have marked your username and will never respond to your post.



bro, we no dey fight na, this is what i did, i move the code back to the external javascript file and applied the function code,
i.e document.getElementById("text"wink.innerHTML=function() {
the action i.e alert(""wink or any action you want it to do.
}

after writing the code just put =function and what you want it to do .

thanks for pointing out my mistake bro
Re: Which Is Better Inline Javascript Or External Javascript by Nobody: 7:22am On Jan 27, 2016
I was just joking o jare, you did well by-the-way!
Re: Which Is Better Inline Javascript Or External Javascript by sinequanon: 11:08am On Jan 27, 2016
nunamyeong:




bro, we no dey fight na, this is what i did, i move the code back to the external javascript file and applied the function code,
i.e document.getElementById("text"wink.innerHTML=function() {
the action i.e alert(""wink or any action you want it to do.
}


after writing the code just put =function and what you want it to do .

thanks for pointing out my mistake bro

This is not what fixed your code. You may have done something else without realizing it.

All you need to show us your example is to copy and paste the code in your small html file into your post and put it inside code tags (by clicking the # button next to the quote button). Do the same with a small external file. Leave out everything that is not relevant to the problem.

What is important here is the order in which you have written your code, so giving us a couple of lines separately doesn't help us to help you.

(1) (Reply)

Learn Python Django In A Week / How Important Is Data Structures And Algorithm To Pro Developers / Can Qbasic Interact With Any DBMS ?

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 20
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.