Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 03-28-2012, 10:56 PM   PM User | #16
blaze4218
Regular Coder

 
Join Date: Apr 2005
Location: Texas
Posts: 448
Thanks: 24
Thanked 63 Times in 63 Posts
blaze4218 is an unknown quantity at this point
Quote:
Unless you are a JavaScript expert there's no point in even thinking about...
I feel almost guilty dragging this thread any further, but I really must address this point.

I too appreciate felgall's candor. I feel that we can all improve through this very discourse, not to mention felgall did present points that should be considered by cryoffalcon (and all others)

But there must be a better way to present such ideas than telling a person that "if your not already the best, you should wait until you are the best before learning something that could improve/further your knowledge"... such comments are both unnecessary and judgmental (not to mention flat out wrong) and have no place here.

There are instances in which new scripters over-reach and try to create a shopping cart checkout, or capture personal information with JavaScript; and by all means, let us thwart such efforts. But experimentation with combining scripts can only serve to aid in ones understanding of how the language actually works, and I for one learned a great deal by dabbling in things I had yet to understand (in a stable environment). So by all means- offer your two cents, and further elaborate on the topic... but do so with useful information. Don't tell people who are just looking for help, or are just trying to be helpful, that they are too inexperienced to do anything useful and they need to go back to the beginning and learn how javascript really works before asking such questions. I don't think anyone here is qualified to assert what anyone else should or should not spend their time studying.

For example- in this particular case we have an accountant who is just looking to give a little boost to his site's performance, and the conversation has steered into what a waste of time that is and how they should be examining the quality of the code and learning javascript, blah blah blah... Why should this person give two squirts about learning javascript??

In the end what I'm really saying is I agree with what felgall says, but take great concern with how it's being said. It's aggressive, judgmental, and counter-productive. I fear it leads newbies astray...
__________________
Allwisend bin ich nicht, doch viel ist mir bewursst
-Goethe
blaze4218 is offline   Reply With Quote
Old 03-29-2012, 12:50 AM   PM User | #17
Mishu
Banned

 
Join Date: Mar 2012
Posts: 306
Thanks: 1
Thanked 28 Times in 28 Posts
Mishu can only hope to improve
There's nothing wrong with combining scripts as long as you take care to handle any potential conflicts.

I always start with one general script file for the website and add to it as required. The main reason I like to have just one js file is that my Netbeans IDE then lists all the functions in the navigation pane in alphabetical order and to go to a function in the js file I just double-click the function in the navigation pane and I then get taken straight to it. No stuffing around scrolling up and down or using the find feature in a js file to look for a function.

My js files are small and so the loading time is unnoticeable for me and so irrelevant.
Mishu is offline   Reply With Quote
Old 03-29-2012, 02:19 AM   PM User | #18
venegal
Gütkodierer


 
Join Date: Apr 2009
Posts: 2,127
Thanks: 1
Thanked 426 Times in 424 Posts
venegal has a spectacular aura aboutvenegal has a spectacular aura about
A few comments here; I won't quote anyone in order to not make this thread any more inflammatory, but there's a bunch of things that might be relevant to the OP's questions:

a) The original idea behind combining scripts was not just about a minor millisecond optimization. Depending on the user location, the ping to your server can easily be 300ms, and when scripts are loaded sequentially, serving ten separate script files instead of one can make a difference of 3 seconds in loading time, which has a huge impact on user experience (so this isn't really about server load optimization). Browsers are smarter now, of course, but it's still not a bad idea to combine scripts in production.

b) When I say "in production" I mean exactly that: Of course you will want to leave your code neatly seperated into different files for maintenance reasons, but it's a great idea to combine and, for that matter, minify them in your production environment. Clearly that's much too tedious to do manually, but you can easily write a piece of server side code to do that for you, which you can reuse for all your websites.

Some pseudocode might look like that:

Code:
if production (probably meaning server name isn't localhost) {
	if production script file has a more recent last changed timestamp than all your development script files, do nothing
	else combine and minify all your development scripts and write the result to the production script file
	output script tag for the production script file
}
else {
	output seperate script tags for all the development script files
}
c) On a semantic level, it's impossible to cause any conflicts by combining scripts. If there's a variable conflict or a dependency problem after combining, it has already been there before. On a syntactic level, you can get into trouble if 1.) you're lacking a rigorous use of semicolons and 2.) you don't put a newline between scripts — the interpreter won't know then where the last statement ends. But that's pretty much all you have to worry about.

d) There's almost always more harm than benefit in serving different scripts to different pages. Serving a single script gives you the obvious cache advantage, of course, but it's also noteworthy that the fact that that single combined file will be significantly larger than a specific file you might be serving to a specific page is pretty much irrelevant: With increasing bandwidths, network latency becomes much more relevant than file size. Network latency pretty much comes down to the speed of light, which won't change any time soon, so an additional HTTP request per page will have larger and larger impacts on overall load time as bandwidths increase. With current average bandwidths, this means that serving the same 10k of Javascript to all the pages will be much better for international user experience than serving 10 different 1k files to 10 different pages. (That 1.5m Javascript file mentioned before is absurd, unless you write really crappy code.)
__________________
.My new Javascript tutorial site: http://reallifejs.com/
.Latest article: Calculators — Tiny jQuery calculator, Full-fledged OOP calculator, Big number calculator
.Latest quick-bit: Including jQuery — Environment-aware minification and CDNs with local fallback
venegal is offline   Reply With Quote
Old 03-29-2012, 10:04 AM   PM User | #19
cryoffalcon
Regular Coder

 
Join Date: Oct 2010
Posts: 157
Thanks: 2
Thanked 1 Time in 1 Post
cryoffalcon is an unknown quantity at this point
[QUOTE=Philip M;1209520]Really? Most accountants are literate and know that the personal pronoun I is a capital letter.

Well to make it more accurate Chartered Accountant. And as far as 'i' is concerned you should know we use Excel kind of stuff that corrects the grammar stuff for us, so you can call it a bad habit ^_^
cryoffalcon is offline   Reply With Quote
Old 03-29-2012, 10:12 AM   PM User | #20
cryoffalcon
Regular Coder

 
Join Date: Oct 2010
Posts: 157
Thanks: 2
Thanked 1 Time in 1 Post
cryoffalcon is an unknown quantity at this point
Quote:
And I too wish people would stop writing "i' for I (sorry cryoffalcon!), but then I wish we still wore spats and braces. But seriously, I am of the opinion that taking the same care with language is part of the same technique of getting things right with that literal beast javascript. So it should pay dividends to do so.
Well don't be sorry, its okay i understand. I am not a script writer but i do am CSS writer and i understand the seriousness of writing correct codes. One time i just forgot to place a closing bracket at the end of a class and my whole CSS was bringing really weird results. Until i found that i have mistakenly deleted it while deleting the lower code.
Javascript is my favorite but as its hard so i am scared of it and learning it slowly and i am not going to correct this 'i' just to tease some more fellas :P i am kidding. But what can i do its a bad habit
cryoffalcon is offline   Reply With Quote
Old 03-29-2012, 10:15 AM   PM User | #21
Philip M
Supreme Master coder!

 
Philip M's Avatar
 
Join Date: Jun 2002
Location: London, England
Posts: 17,044
Thanks: 197
Thanked 2,412 Times in 2,390 Posts
Philip M has a spectacular aura aboutPhilip M has a spectacular aura aboutPhilip M has a spectacular aura about
In this day and age with 100 applications for each job vacancy, a surefire way to get your cv chucked in the wastebin right away is to reveal literacy problems with poor grammar, poor spelling and/or poor punctuation. And clients of professional firms dislike receiving reports etc. with "uncorrected grammar stuff". Your bad habit could cost you dear. And you seem to be blissfully unware of the important difference betweeen its and it's.
__________________

All the code given in this post has been tested and is intended to address the question asked.
Unless stated otherwise it is not just a demonstration.

Last edited by Philip M; 03-29-2012 at 10:18 AM..
Philip M is offline   Reply With Quote
Old 03-29-2012, 10:20 AM   PM User | #22
cryoffalcon
Regular Coder

 
Join Date: Oct 2010
Posts: 157
Thanks: 2
Thanked 1 Time in 1 Post
cryoffalcon is an unknown quantity at this point
Quote:
Originally Posted by blaze4218 View Post
I feel almost guilty dragging this thread any further, but I really must address this point.

I too appreciate felgall's candor. I feel that we can all improve through this very discourse, not to mention felgall did present points that should be considered by cryoffalcon (and all others)

But there must be a better way to present such ideas than telling a person that "if your not already the best, you should wait until you are the best before learning something that could improve/further your knowledge"... such comments are both unnecessary and judgmental (not to mention flat out wrong) and have no place here.

There are instances in which new scripters over-reach and try to create a shopping cart checkout, or capture personal information with JavaScript; and by all means, let us thwart such efforts. But experimentation with combining scripts can only serve to aid in ones understanding of how the language actually works, and I for one learned a great deal by dabbling in things I had yet to understand (in a stable environment). So by all means- offer your two cents, and further elaborate on the topic... but do so with useful information. Don't tell people who are just looking for help, or are just trying to be helpful, that they are too inexperienced to do anything useful and they need to go back to the beginning and learn how javascript really works before asking such questions. I don't think anyone here is qualified to assert what anyone else should or should not spend their time studying.

For example- in this particular case we have an accountant who is just looking to give a little boost to his site's performance, and the conversation has steered into what a waste of time that is and how they should be examining the quality of the code and learning javascript, blah blah blah... Why should this person give two squirts about learning javascript??

In the end what I'm really saying is I agree with what felgall says, but take great concern with how it's being said. It's aggressive, judgmental, and counter-productive. I fear it leads newbies astray...
Well i am really glad what you wrote is what we newbies feel ^_^
It do scares the **** out of a person who already knows that javascript is not like CSS which has a language that close to english
Being an accountant (as i am not genius of script writing as you guys) i always follow one philosophy that i need to "learn how to use TV rather than how it was invented or made" in most cases i do know how to handle scripts i am not blind but the reality is i can't write, so if you come up with talks like Variables, strings etc you should know i will not understand a single word

Just at the footnote, during my accounting life we were told and guided that always use simple and easy language to convey a message (don't use accounting terminologies) as everyone is not accountant or maybe is but not at your level ^_^
cryoffalcon is offline   Reply With Quote
Old 03-29-2012, 10:30 AM   PM User | #23
cryoffalcon
Regular Coder

 
Join Date: Oct 2010
Posts: 157
Thanks: 2
Thanked 1 Time in 1 Post
cryoffalcon is an unknown quantity at this point
Quote:
Originally Posted by Philip M View Post
In this day and age with 100 applications for each job vacancy, a surefire way to get your cv chucked in the wastebin right away is to reveal literacy problems with poor grammar, poor spelling and/or poor punctuation. And clients of professional firms dislike receiving reports etc. with "uncorrected grammar stuff". Your bad habit could cost you dear. And you seem to be blissfully unware of the important difference betweeen its and it's.
Well it will hurt your feelings to tell you a few things about me :P when i am chating or taking on internet i don't mind to you atleast instead of at least. Grammar is part of my job, i don't like to use it over internet where we all use Short Hand. If you want to bring out mistakes you can point out we don't make faces in reports or CV like this ^_^

As far as my job is concerned right now i work as Reporting and Admin Officer at Minsitry of Urban Development. I have previously worked for WFP (its part of UN) as Finance Officer other jobs includes working as Finance Manager at Private Limited.
My education includes (Pr-Engineering + ACCA + BSC Hons) i have skills in many computer programs and a few web languages (though i am not smart you computer guys, i know)
And my age is 22 years, my work experience is of almost 4 years (full time).
The reason of saying all this is not to show something i am just saying that i know stuff about interviews, reports etc as i met and have relations with some big people (you can expect me to have a professional behavior) but still at the end i would say, i don't like to stay professional on internet, its boring ^_^
cryoffalcon is offline   Reply With Quote
Old 03-29-2012, 10:52 AM   PM User | #24
Philip M
Supreme Master coder!

 
Philip M's Avatar
 
Join Date: Jun 2002
Location: London, England
Posts: 17,044
Thanks: 197
Thanked 2,412 Times in 2,390 Posts
Philip M has a spectacular aura aboutPhilip M has a spectacular aura aboutPhilip M has a spectacular aura about
Quote:
Originally Posted by cryoffalcon View Post
And my age is 22 years, my work experience is of almost 4 years (full time).
Wow! As much as almost 4 years! Obviously you are in the happy state of still being young enough to know everything!

What you do is of no consequence to me. But as I say, were it me your cv would not get past the first scanning.


Quote:
Originally Posted by cryoffalcon View Post
i met and have relations with some big people
Really?
__________________

All the code given in this post has been tested and is intended to address the question asked.
Unless stated otherwise it is not just a demonstration.
Philip M is offline   Reply With Quote
Old 03-29-2012, 10:57 AM   PM User | #25
Mishu
Banned

 
Join Date: Mar 2012
Posts: 306
Thanks: 1
Thanked 28 Times in 28 Posts
Mishu can only hope to improve
Quote:
Originally Posted by cryoffalcon View Post
Grammar is part of my job, i don't like to use it over internet where we all use Short Hand. If you want to bring out mistakes you can point out we don't make faces in reports or CV like this ^_^
Totally agree . The environment like forums like this is totally different to putting together a cv and i don't care less about the relatively common shorthand used in forum posts, social networking posts etc. My only pet hate is the occasional total absence of at least some punctuation which makes some posts a little awkward to read sometime for me.

If I needed to put a cv together I would make sure it was written in the queen's english.
Mishu is offline   Reply With Quote
Old 03-29-2012, 11:02 AM   PM User | #26
Philip M
Supreme Master coder!

 
Philip M's Avatar
 
Join Date: Jun 2002
Location: London, England
Posts: 17,044
Thanks: 197
Thanked 2,412 Times in 2,390 Posts
Philip M has a spectacular aura aboutPhilip M has a spectacular aura aboutPhilip M has a spectacular aura about
Quote:
Originally Posted by Mishu View Post
If I needed to put a cv together I would make sure it was written in the queen's english.
I doubt it. The Queen's Strine possibly.

Shorthand is by no means the same thing as poor grammar, poor spelling and/or poor punctuation.
__________________

All the code given in this post has been tested and is intended to address the question asked.
Unless stated otherwise it is not just a demonstration.

Last edited by Philip M; 03-29-2012 at 11:08 AM..
Philip M is offline   Reply With Quote
Old 03-29-2012, 11:18 AM   PM User | #27
cryoffalcon
Regular Coder

 
Join Date: Oct 2010
Posts: 157
Thanks: 2
Thanked 1 Time in 1 Post
cryoffalcon is an unknown quantity at this point
Quote:
Originally Posted by Philip M View Post
I doubt it. The Queen's Strine possibly.

Shorthand is by no means the same thing as poor grammar, poor spelling and/or poor punctuation.
Well i don't know but i think you are a very strict person Philip
and as far as my 'big people' thing is concerned i mentioned it just to show that i know how to behave professionally when i am talking to Ministers at a meeting (personal or work reasons). It was not that i am a hot shot. I know my CV will not go through first scanning if its like that but do you expect me to do that ^_^
I know you follow the philosophy "don't say i am professional but also look like one" i don't look like one but i told i am and more important thing here is we all behave here as geeks, we don't follow rules or stuff but we like to create some that's what i guess Programming is.
I don't want to waste time on english rather on scripting (when i am doing the thing that makes me relax done after work, Coding or Developing) I always say "By profession i am a chartered accountant but by passion i am a developer"
In the end i would say you are "Totally Right" about what you are saying but its just that i want to live free on internet and there are few guys 'crazy' like me.

Last edited by cryoffalcon; 03-29-2012 at 11:26 AM..
cryoffalcon is offline   Reply With Quote
Old 03-29-2012, 12:24 PM   PM User | #28
tpeck
Regular Coder

 
tpeck's Avatar
 
Join Date: Oct 2002
Location: Sydney, Australia
Posts: 771
Thanks: 40
Thanked 5 Times in 4 Posts
tpeck is on a distinguished road
I don't think it's possible to cherry-pick your way through accuracy in your life as a developer. You either strive to be a careful person or you don't. Eventually you pay for what you don't do or choose to do poorly and get left behind by those with higher standards. It's a tough world out there.

Since contributors to this forum strive to help each other, it's the least we can do to point this out. No-one minds a slip or two, but deliberate inaccuracy is self-defeating. Many contributors will pass on a poorly written thread. And that will cost you time and eventually money. It's the same in every profession. Those who take care go places. Hollywood has done us all a great disservice by having the mumblers and short-cut takers succeed so often. In real life they just lose.

Sermon over. Have a nice life.
__________________
The difference between genius and stupidity is that genius has its limits. (Albert Einstein)
tpeck is offline   Reply With Quote
Users who have thanked tpeck for this post:
Philip M (03-29-2012)
Old 03-29-2012, 01:12 PM   PM User | #29
Mishu
Banned

 
Join Date: Mar 2012
Posts: 306
Thanks: 1
Thanked 28 Times in 28 Posts
Mishu can only hope to improve
Quote:
Originally Posted by tpeck View Post
Eventually you pay for what you don't do or choose to do poorly and get left behind by those with higher standards.
In forums like this when talking about grammar blah blah I think before judging anyone on their ability to write good english, whether english is someone's native language or not shouild be taken into consideration.

What is also important is to know what is poor english and what is good because then you can use either where it is acceptable. In forums and social networking environments poor english is accpetable to me as long as the message is clear, although sometimes it won't be.

If writing cv's reports, articles blah blah then obviously poor english isnt acceptable and so you can't get away with it like you can in social networking and forums.
Mishu is offline   Reply With Quote
Old 03-29-2012, 01:22 PM   PM User | #30
tpeck
Regular Coder

 
tpeck's Avatar
 
Join Date: Oct 2002
Location: Sydney, Australia
Posts: 771
Thanks: 40
Thanked 5 Times in 4 Posts
tpeck is on a distinguished road
You're missing the point, sorry. One's first language is irrelevant if you know to do something but choose not to.
__________________
The difference between genius and stupidity is that genius has its limits. (Albert Einstein)
tpeck is offline   Reply With Quote
Reply

Bookmarks

Tags
combining, compressor, external, javascript

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 08:56 PM.


Advertisement
Log in to turn off these ads.