web developing
8 Jan
The question is: should I use always jQuery in some large jQuery project? Imagine you’re developing a large scale web application where the JavaScript part of it is supported by jQuery. In my case that was the reality. In fact in every, even very big, project there are “pages” where you don’t need much of JavaScript. Such pages can be the “about”, “info” or whatever static page there is.
Well the question is, should I again include the hole jQuery if I need only to toggle the visiblity on a DIV element? Let’s assume you’ve very long text, cutted in the beggining with the “more” link somewhere after the intro. That’s very common, isn’t it? So by clicking on the “more” you toggle the visibility of the rest of the text. Well of course it’s absurt if I include the entire library just to make this.
The right answer by me is to use pure JavaScript, something like that:
document.getElementId('id').style.display = 'block'
That will do the same job without to block the “fast” in other way page!
Related posts:
6 Responses for "jQuery vs. pure JavaScript"
What is point of using javascript on single page, if jQuery is going to be loaded by visitor, anyway? (on other pages)
Just hotlink to google code to save bandwith for both your server and visitor.
Well nobody says that jQuery is loaded on every page! And there’s the answer of your question!
best regards,
stoimen
jquery is a toolkit not a manacle – do whatever you want. The only reason I would use it in this case is if I am using ’slow fades’ or similar effects on other pages and want this to be the same.
The code will be cached locally from other pages, so the only delay would be the time taken to parse the code – negligible on any modern pc.
John
Hi John,
OK if you’d like to use effects it’s better to include the library. However I know that jQuery is, but the question is not what’s the difference between jQuery and JavaScript, this is nonsense, but whether you need all the functionality given by jQuery just for a simple effect.
Another thing I won’t agree is that the code will be cached. If you code a page with the presumption in mind that everything is cached before “that page is loaded” sooner or later you’d know that not everybody’s using cache enabled browser, gzip or whatever good thing that web developers would like to be enabled. It’s not bad if you start developing with optimization in mind.
greetings,
stoimen
My answer is yes.Yes, just go on with JQuery. Although I’m using Mootool in my new project, http://quickmessageapp.com, or whatever javascript framework, *It* will simplify your job.
Just imagine, how big javascript framework and how fast internet connection nowdays? 24-68 KB just a second or two on todays broadband.
Just my two cents
Second or two? That’s too much for a website it must load the entire site for a second, not only the javascript framework.
Leave a reply