bower custom build of jqueryui

Deadly 提交于 2019-12-18 18:38:01

问题


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.


回答1:


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.




回答2:


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>


来源:https://stackoverflow.com/questions/15056677/bower-custom-build-of-jqueryui

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!