How do I include plugins in HTML5 Boilerplate (plugins in individual .js-files, local testing)

梦想与她 提交于 2019-12-13 06:01:15

问题


I'm testing out HTML5 Boilerplate, but I don't quite get how to setup the plugins.js-file.

I've tried to copy the contents of plugins in manually, like this:

(function($){
   //minimized source of plugin #1
})(this.jQuery);

(function($){
   //minimized source of plugin #2
})(this.jQuery);

//and so on...

But it got quite time consuming and hard to maintain.

I then tried to use the "vender"-folder and include from there:

$.getScript("vendor/waypoints.min.js", function(){
   alert("Success");
});

But then I get the following errors (Chrome console) when testing locally:

OPTIONS file:///Users/myusername/Sites/H5BPtest/js/vendor/waypoints.min.js?_=1371722230114 Origin null is not allowed by Access-Control-Allow-Origin.

XMLHttpRequest cannot load file:///Users/myusername/Sites/H5BPtest/js/vendor/waypoints.min.js?_=1371722230114. Origin null is not allowed by Access-Control-Allow-Origin. 

What to do? I would prefer to have all plugins in a folder (e.g. "vendor"), and then load them somehow.

Also an automated solution that takes alle the .js-plugin-files and combines them to one, would be cool. But I haven't seen any easy to use solutions on that (I'm not that technical)...

I need to test locally, because I'm using some design tools, that doesn't work via a server. I'm on OSX, if it makes any difference.

Any help would be very, very appreciated!

来源:https://stackoverflow.com/questions/17211041/how-do-i-include-plugins-in-html5-boilerplate-plugins-in-individual-js-files

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