Since JavaScript was first created there have been a number of additional features added into the language. A number of these additions made possible all sorts of additional cleaner ways in which the JavaScript can be written that allow it to interact more with the web page while being able to keep the script completely separate from the HTML and any other scripts you may want to have attached to the same page.
Of course all of the original JavaScript still works the same as it did back when that was all that JavaScript allowed, it just isn't the best way to do things any more.
One problem with all these antiquated JavaScripts is that they still work and it is really easy to take the approach of "if it ain't broke, don't fix it". For many web sites that will be a perfectly valid approach to take and old scripts will only be slowly modernised as changes to the site mean that it is easier to rewrite the script to use modern unobtrusive processing instead of trying to patch the original.
There are also a lot of people who don't have the time to learn JavaScript properly but need to add some quick JavaScript into their web page where either there is no existing script they can copy so that they have to patch something together quickly themselves or the script that they find to use is an older style one that works but doesn't use the most modern JavaScript techniques. There is nothing wrong with these people taking this approach since their situation is one where having something that works now is more important than following the current best coding practices.
After all JavaScript may take a person several months to learn properly compared to the one or two days that learning proper coding of HTML takes and so there is far more justification for using a badly written JavaScript that works than there is for using badly written HTML. Anyway, you'll need your HTML to be written correctly for the JavaScript to work properly regardless of how the JavaScript is written.
Those who haven't learnt to write their own JavaScript and who just use scripts written by other people have a far larger selection of old scripts to choose from than they do of modern unobtrusive scripts.
There are several reasons for this including that there are so many such scripts that have already been written and made available for use, that some script repositories just list all the working scripts that are provided to them including those patched together by people who haven't learnt to write modern unobtrusive JavaScript, and of course since it takes time to update scripts there are simply lots of scripts around where the person who wrote the script will update the script to use more modern techniques just as soon as they find the time to do so (or perhaps remember that it exists and hasn't been updated yet).
In some cases the older script is retained along with a link to a more modern version of the same script. This approach helps to make it clear to those who may have been using the old script for some time that the new script will provide the equivalent functionality in a less obtrusive manner as well as acting as an example for those who write their own scripts and want to see the sorts of changes that need to be made to modernise a script. By comparing the old and new versions of the script they can see what sorts of alterations they might need to make to modernise their own scripts.
For as long as the old scripts continue to work, they will never disappear entirely from the web since they do serve several useful purposes even where there are better ways of coding available now. Future additions to JavaScript will probably mean that what is considered to be best practice now will eventually be considered to be less than perfect way of writing your code and those scripts too will then be ones that will eventually need to be considered for rewriting to use the better coding techniques that were developed subsequent to the script being written.
For as long as JavaScript continues to evolve there will be new better ways of writing the code that are introduced into the language and more and more of the scripts that are in use will be considered to use a less than optimal approach in the way that they are written.
Of course all of the original JavaScript still works the same as it did back when that was all that JavaScript allowed, it just isn't the best way to do things any more.
One problem with all these antiquated JavaScripts is that they still work and it is really easy to take the approach of "if it ain't broke, don't fix it". For many web sites that will be a perfectly valid approach to take and old scripts will only be slowly modernised as changes to the site mean that it is easier to rewrite the script to use modern unobtrusive processing instead of trying to patch the original.
There are also a lot of people who don't have the time to learn JavaScript properly but need to add some quick JavaScript into their web page where either there is no existing script they can copy so that they have to patch something together quickly themselves or the script that they find to use is an older style one that works but doesn't use the most modern JavaScript techniques. There is nothing wrong with these people taking this approach since their situation is one where having something that works now is more important than following the current best coding practices.
After all JavaScript may take a person several months to learn properly compared to the one or two days that learning proper coding of HTML takes and so there is far more justification for using a badly written JavaScript that works than there is for using badly written HTML. Anyway, you'll need your HTML to be written correctly for the JavaScript to work properly regardless of how the JavaScript is written.
Those who haven't learnt to write their own JavaScript and who just use scripts written by other people have a far larger selection of old scripts to choose from than they do of modern unobtrusive scripts.
There are several reasons for this including that there are so many such scripts that have already been written and made available for use, that some script repositories just list all the working scripts that are provided to them including those patched together by people who haven't learnt to write modern unobtrusive JavaScript, and of course since it takes time to update scripts there are simply lots of scripts around where the person who wrote the script will update the script to use more modern techniques just as soon as they find the time to do so (or perhaps remember that it exists and hasn't been updated yet).
In some cases the older script is retained along with a link to a more modern version of the same script. This approach helps to make it clear to those who may have been using the old script for some time that the new script will provide the equivalent functionality in a less obtrusive manner as well as acting as an example for those who write their own scripts and want to see the sorts of changes that need to be made to modernise a script. By comparing the old and new versions of the script they can see what sorts of alterations they might need to make to modernise their own scripts.
For as long as the old scripts continue to work, they will never disappear entirely from the web since they do serve several useful purposes even where there are better ways of coding available now. Future additions to JavaScript will probably mean that what is considered to be best practice now will eventually be considered to be less than perfect way of writing your code and those scripts too will then be ones that will eventually need to be considered for rewriting to use the better coding techniques that were developed subsequent to the script being written.
For as long as JavaScript continues to evolve there will be new better ways of writing the code that are introduced into the language and more and more of the scripts that are in use will be considered to use a less than optimal approach in the way that they are written.
SHARE