casperOneMatrym提出了一个问题:HTML5 Boilerplate plugins.js,或许与您遇到的问题类似。
回答者borkweb给出了该问题的处理方式:
That section of the html5boilerplate is sort of an abbreviation of what should/could go there.
You can approach plugins.js a few ways:
- Ignore it and include all of your JS plugins as separate files (undesirable)
- Manually concatenate and minify the plugin files (this is a pain to maintain)
- Use a script to concatenate them (and cache it) at run-time (like this)
- Use a makefile to concatenate/compress like a ninja (like this)
- Use a slick JS library like yepnope.js to asynchronously load your plugin files as needed.
There's a lot of options for including your JS plugins...you'll have to weigh them yourself, of course. I usually use options 3 or 4, though I need to start using 5.
As for what goes in the snippet of code that you gave:
(function($){ // This is a wrapper for your jQuery stuff })(this.jQuery);
You'll see that block of code wrapping a lot of jQuery plugins (check the docs). It can be used to wrap your jQuery-specific code so you can make use of $
while keeping your site in jQuery compatibility mode...which lets your site play nicely with other libraries that may use $
as well.
希望本文对你有帮助,欢迎支持JavaScript中文网
来源:JavaScript中文网 ,转载请注明来源 https://www.javascriptcn.com/post/28251