Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Should I load entire jQuery UI JS/CSS or only the parts that I need on a certain page?

I know what many of you will say. This is a stupid question, or maybe this is not the right forum, or depend on the application, etc.

I am just wondering if I have a custom theme, that I might change in future is it a good idea to separate the jQuery UI, I mean the JS classes and CSS in smaller chunks (files like droppable,etc.) and include only the one that I need on certain page or keep them together and load the entire UI on every page. Both have positives and negatives. I am just not sure which is better.

What is your opinion. Any different approach possible?

like image 215
Yasen Zhelev Avatar asked Feb 04 '11 09:02

Yasen Zhelev


People also ask

What is the need of jQuery UI in real 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.

Do you need jQuery for jQuery UI?

It really depends on what you want to do. If you just need basic DOM manipulation, even handling, and things like that, then use jquery. js. If you need advanced UI components and functionality (dragging and dropping, sorting, etc.)

Is jQuery UI good?

It is a free and open-source library built on top of the jQuery JavaScript Library. Being lightweight, fast, and easy to use, jQuery UI is one of the most popular and powerful JS libraries to develop highly interactive web applications.

Is jQuery UI still supported?

Support for jQuery 1.7 has been dropped; jQuery 1.8 & newer remain supported. In this release, all individual module files as well as bundled jQuery UI copies produced by the Download Builder have all its code running in strict mode.


2 Answers

My personal opinion is, if you want to keep up to date in the future, it would be far easier to keep the jQuery UI files complete, otherwise in the future to update you will have to spend time splitting the new versions.

If there are features you know you don't and won't use, you could remove those during the download by simply selecting the features you will use.

I also think the load time would be insignificant, once the browser has loaded the script, it is likely to cache a copy of it so a user isn't reloading the script with every page. Plus the server only has to serve two files, instead of the overheads to potentially serve multiple files.

It will also help for future development of your site scripting in the sense if you want to add an extra feature to your script, you won't need to remember if you have loaded the required js/css part files.

like image 51
Scoobler Avatar answered Nov 04 '22 09:11

Scoobler


i think it will be better if you load entire jQuery ui js/css, because if in future if you want to do some thing new in jquery then again you have to look at those parts which would be required to do this stuff, and you have to make extra efforts to put those chunk of code in your js file so i think loading the entire jquery will be better approach!!

like image 42
Vivek Avatar answered Nov 04 '22 10:11

Vivek