You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The appView code in architecture-examples/backbone/js/views/app.js is wrapped in an unnecessary jQuery DOMReady check. While this is a good idea for the main App initialization (the top-level app.js), it can slow the app from rendering (slight as it is) because it waits for the DOM to be ready before doing anything.
It also shows $ as a parameter but doesn't pass anything explicitly. This could lead to a conflict if other code did something to $. It would be more explicit that we're using jQuery if we passed it to the immediately invoked function expression.
Both of the above things can be accomplished by simply changing:
$(function ($) {
use 'strict';
app.AppView = Backbone.View.extend({
...
});
To:
(function ($) {
use 'strict';
app.AppView = Backbone.View.extend({
....
}){jQuery);
Well, technically it's not a module pattern since we're not returning anything.
This same technique would also go for any of the Backbone Views, such as views/todos.js -- which accesses jQuery via an "implied global" called $.
If this sounds reasonable, I can submit a patch. Thanks.
The text was updated successfully, but these errors were encountered:
The appView code in architecture-examples/backbone/js/views/app.js is wrapped in an unnecessary jQuery DOMReady check. While this is a good idea for the main App initialization (the top-level app.js), it can slow the app from rendering (slight as it is) because it waits for the DOM to be ready before doing anything.
It also shows $ as a parameter but doesn't pass anything explicitly. This could lead to a conflict if other code did something to $. It would be more explicit that we're using jQuery if we passed it to the immediately invoked function expression.
Both of the above things can be accomplished by simply changing:
To:
Well, technically it's not a module pattern since we're not returning anything.
This same technique would also go for any of the Backbone Views, such as views/todos.js -- which accesses jQuery via an "implied global" called $.
If this sounds reasonable, I can submit a patch. Thanks.
The text was updated successfully, but these errors were encountered: