I've recently inherited the maintenance of a big, ugly codebase for a production website. Poke your eyes out ugly. And though it's big, it's mostly PHP code, it doesn't have much JS, besides a few "ajaxy" things in the UI.
Our main current problem is that the site is just too heavy. Homepage weighs in at 1.6 Mb currently, so I'm trying to clean some stuff out.
One of the main wasters is that every single page includes the jQuery UI library, but I don't think it's used at all. It's definitely not being used in the homepage and in most pages, so I want to only include the where necessary.
I'm not really experienced with jQuery, i'm more of a Prototype guy, so I'm wondering. Is there anything I could search for that'd let me know where jQuery UI is being used?
What i'm looking for is "common strings", component names, etc
For example, if this was scriptaculous, i'd look for things like "Draggable", "Effect", etc. Any suggestions for jQuery UI?
(Of course, if you can think of a more robust way of removing the tag from pages that don't use it without breaking everything, I'd love to hear about it)
Thanks!! Daniel
The jQuery project is actively maintained and widely implemented — it's used by 73% of 10 million most popular websites.
jQuery UI is a curated set of user interface interactions, effects, widgets, and themes built on top of the jQuery JavaScript Library. Whether you're building highly interactive web applications or you just need to add a date picker to a form control, jQuery UI is the perfect choice.
JQuery is basically the base of JQuery UI and is the more powerful between the two. It should be used for more advanced work that requires custom code and interactions. For basic user interface needs, using the JQuery UI is very beneficial as it reduces the complexity of coding and speeds up the entire process.
jQuery is a lightweight, "write less, do more", JavaScript library. The purpose of jQuery is to make it much easier to use JavaScript on your website. jQuery takes a lot of common tasks that require many lines of JavaScript code to accomplish, and wraps them into methods that you can call with a single line of code.
jQuery UI has a standard naming convention, you can view a full list of widgets/effects here. Comparing to that list you're looking for the corresponding methods mostly:
.draggable()
.droppable()
.dialog()
However, and this is a big however, if your main goal is to reduce page payload size, this should have no effect. Your users shouldn't be downloading this every page load, it should be cached on the client as determined by cache headers, additionally your scripts should be minified (already provided version when you download it) and delivered gzipped.
Also if it's an option, I'd consider using a CDN for both jQuery and jQuery UI, and the stylesheets as well, if you're using one of the default themes.
My advice would be to look at the jQuery UI demo page - http://jqueryui.com/demos/ - and look at each demo and search for the main one or two keywords from each demo, like you would probably do for Scriptaculous. Good luck.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With