What are jQuery's most important challenges, and what as a developer can I do about them? -
i have project coming build interface allows user construct content pre-defined templates , code snippets.
we've decided use jquery , jquery ui frameworks dragging/dropping/sorting parts. there needs edit-in-place, , i'm going use contenteditable
combined jquery's css functions.
i have quite bit of experience both frameworks (and love them), typical project far has run 50 lines whereas 1 run lot more that, using more of functions , writing own plugins.
before start work on project i'm wondering if there common pitfalls jquery - kind of 'jquery - bad parts'. there functions best avoided? there functions need working around?
i read this link it's 2 years old , lot has changed in jquery (and browsers) since then.
any 'use framework instead' or 'don't use framework' answers ignored - have use jquery. 'jquery rubbish' rants don't provide solutions ignored. constructive comments please. if knew how better in javascript jquery does, wouldn't using jquery.
i'll answer half of question. here's laundry list of pitfalls based on painful experience, not of have solutions to.
- the temptation make heavy use of long chains of selectors ("ul#leftnav li p a.current ") makes code brittle. may feel clever ("hey, i'm teh css master!"), breaks when layout changes in non-trivial way.
- using dom database. seems neat idea use .data() attach data dom elements, track page state, , link dom elements together, if go overboard, start lose track of what's where.
- putting way stuff in $(document).ready(). once again, it's natural initialize events , data here, run organizational , ordering problems. mvc-like solutions keep things organized.
- not quite cross-browser. test in targeted browsers , often! jquery, although wonderful abstraction, still leaky one. events , attributes don't behave same in different js engines.
Comments
Post a Comment