Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

bower custom build of jqueryui

In Bower, how do I get and continue to update a custom build of jQuery UI? Let's say I only need components for Core, Widget, Mouse, Position, Sortable, and Accordion in jQuery UI? I rather not download the entire jQuery UI library.

like image 235
wwwuser Avatar asked Feb 24 '13 21:02

wwwuser


2 Answers

To give a practical example of a possible approach and to answer to Egg's comment here's a way to do it.

Just bower install the whole thing as suggested by Sindre and include only the scripts that you need in the html.

   <script src="bower_components/jquery/dist/jquery.js"></script>
   <script src="bower_components/jquery-ui/ui/core.js"></script>
   <script src="bower_components/jquery-ui/ui/widget.js"></script>
   <script src="bower_components/jquery-ui/ui/mouse.js"></script>
   <script src="bower_components/jquery-ui/ui/sortable.js"></script>
   <script>
     (function() {
       $( "#some-div" ).sortable();  // it works!
     })();
   </script>

  </body>
</html>

This will already work and reduce significantly the file size of the libraries downloaded by the user when using your app or website. Here is a post about this straight from the horse's mouth.

To further increase download speed you can then create your own bundle in your preferred way, maybe using Grunt usemin or whatever else method you fancy to get to this kind of html:

   <script src="scripts/bundle.min.js"></script>
   <script>
     (function() {
       $( "#some-div" ).sortable(); // it works!
     })();
   </script>

  </body>
</html>
like image 77
Aurelio Avatar answered Nov 05 '22 08:11

Aurelio


You could have your own fork, but then you would need to keep that up to date too. Just let it download the whole thing and only use the pieces you need, I don't see the problem with that.

like image 5
Sindre Sorhus Avatar answered Nov 05 '22 08:11

Sindre Sorhus