jQuery versions of JavaScript files

Nao

  • Dadman with a boy
  • Posts: 16,079
jQuery versions of JavaScript files
« on May 6th, 2011, 05:12 PM »
Feature: jQuery versions of JavaScript files
Developer: Nao
Target: modders, themers, users, geeks
Status: 100% (believed to be complete and bug-free.)
Comment:

jQuery adds about 31kb to your content the first time you load it. But you may not even realize it: we load jQuery from Google by default, and if another website does the same, chances are the file is already in your browser cache and doesn't need to be loaded.
Still, I'd rather take the worst situation into account and say you're on a 56kbps modem and your browser cache is disabled. You have a right to be silly, we're not judging. So, I solved this problem by saving space everywhere else, optimizing every single bit of SMF's JavaScript code, and using jQuery everywhere it made sense to use it.
For instance, the script.js file in SMF is about 47kb, while the Wedge version clocks in at 27kb. All of the JS files were optimized in a similar fashion, resulting in smaller files, even with jQuery thrown into the process. See the code that applies CSS to the WYSIWYG editor in SMF2? 74 lines. In Wedge? 2 lines. Two.
One of the better aspects of using jQuery in the JS files is that we can also take advantage of its superior capabilities. Sometimes, it will simply replace advantageously an existing feature. The news fader script is 6.6kb in SMF, and 1.6kb in Wedge, with the same outcome.
Other times, I added some nice bits to the SMF formula. The infamous toggler is now much shorter and adds a nice animation effect. We also have the reqWin function. It's called whenever you click a help icon to show a popup with some help text. The Wedge version of reqWin actually opens a div popup with fixed position, with the ability to move it around the page. It works just as well as the SMF version, is non-modal, has some nice subtle visual effects, and frankly, did you ever like SMF's window popups anyway?
There are plenty more examples of the advantages of using jQuery in the JS files, but you'll have to find out for yourself...

Re: jQuery versions of JavaScript files
« Reply #16, on May 9th, 2011, 07:53 PM »
You missed my point.

I pay several times more than you and have less transfer... The extra space isn't that important but I don't have odd CPU caps...

Re: jQuery versions of JavaScript files
« Reply #17, on May 9th, 2011, 07:57 PM »
Quote from Arantor on May 9th, 2011, 07:53 PM
You missed my point.

I pay several times more than you and have less transfer... The extra space isn't that important but I don't have odd CPU caps...
I never got a notice from my host of such things. I don't have any cpu caps as well  :unsure: or not that I'M ware of  :eheheh:

I don't know how other hosts hand that stuff and I'm not really sure how my host handle this. But as an example I don't have such a cpanel thing or something. I have a KIS (client information system) where i can login to add subdomains and other stuff. If you overuse the cpu or something I think it will be handled right by the host itself. There are times when one or another client used to much, but I wonder what they used as it slowed down the whole host.

Well I do like the idea of a own server, but still it would be just to much for my small sites i'm working on  ;)