Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Look at how libraries like Dojo and ExtJS manage this for ideas. They use functions like require() to fetch scripts they depend on dynamically, and to ensure those common libraries aren't loaded twice. They define events to handle load dependencies, so that for example your large list of .ready() statements can be refactored in some places to instead be one important library initializing, then firing off one or more events to indicate certain things are ready, which other libraries use as their cue to initialize.</p> <p>One thing I like to do once multiple coders are coding against the same codebase is to use the HTML/DOM as a mutual contract, and have code tie into it with selectors, as opposed to allowing inline events.</p> <p>For example, if you write a calendar control that has an onclick on the img tag that has to show the calendar, you're making it very difficult for 2 other libraries to come along and key off of the "a calendar control is about to pop up" event. On the other hand, if the library looks for items with CSS className "calendarPick" and attaches an event to them, then you leave open other libraries to do what they will with the same DOM you're sharing, with little or no coordination between coders (writing code that demands coder coordination tends to slow coding down and increase the chances something will break).</p> <p>If that same Calendar library offers some events to key off of it helps other coders get their work done, since if the event is already there they'll likely write it cleanly; if it's not they're more likely to hack it and make the code base less flexible in the process.</p> <p>If you offer singleton methods, for example Calendar.getCalendars(), you'll help make working together easier as well because it prevents people from writing their own version of these methods, locking an implementation in to a specific set of class names, DOM order, or even more fragile circumstances so that everyone's version of this continues to work.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload