At very least the code i gave you will allow you to clean up your own code by subbing document.getElementById() with the $() and i'd say its pretty damn small
Rick On Thu, Apr 30, 2009 at 11:42 AM, Bertrand <[email protected]> wrote: > > Well, actually, my managers are pushing for self-contained javascript > code (trying to get rid of all the library calls, which isn't > necessarily a good idea, but I have to abide). > > So I ended up using a DOM-compliant version using createElement, > createTextNode and appendChild. > > But I'll make sure to give that piece of code of yours a spin. > > Thanks a lot. > > On Apr 29, 3:16 pm, Rick Waldron <[email protected]> wrote: >> Just sort of curious ... of all the convenience that prototype offers, >> why is the only method you "need" is Element.update()? >> >> Anyway, try this... >> >> (function() { >> function _$(args) { >> this.elements = []; >> for (var i = 0, len = args.length; i < len; ++i) { >> if (typeof args[i] == 'string') { >> this.elements.push( document.getElementById(args[i]) ); >> } >> } >> } >> _$.prototype = { >> update: function() { >> this.elements[0].innerHTML = arguments[0]; >> return this; >> } >> }; >> window.$ = function() { >> return new _$(arguments); >> }; >> >> })(); >> >> And a fragment to drop into a body... >> >> <p id="p_content"> >> This is some content that starts in a <p> >> </p> >> <div id="div_content"> >> This is some content that starts in a <div> >> </div> >> <script> >> window.onload = function () { >> $('p_content').update('test'); >> $('div_content').update('test');}; >> >> </script> >> >> On Wed, Apr 29, 2009 at 4:33 PM, Bertrand <[email protected]> wrote: >> >> > That would indeed be another interesting way of doing it. The only >> > problem is that javascript is often used in environments where >> > filesize is critical. In my case, I only use ONE function from the >> > library, because I've found it to be th best way to achieve what I >> > want to do: Element.update. >> >> > But because I'm unable to sort the source code out, I have to either: >> >> > Ditch Prototype altogether (which I don't really want to do) >> >> > OR >> >> > Make use of the whole library, which is a no-go for me as the minified >> > +gzip version still weighs a solid 25kB (which isn't much, but still >> > way too much for our needs). >> >> > What bothers me here is the "one-size-fits-all" mentality, but >> > complaining about it sure is easy when I'm not providing any code to >> > fix the problem, I know it is, but still it bothers me that I'll have >> > to end up not using update (which is a fantastic piece of code, like >> > the rest of the library) just because it's so deeply intertwined with >> > the rest of the codebase. >> >> > What I was hinting at is something akin to what jqueryUI has on >> >http://jqueryui.com/downloadbut even more fine-grained (at function >> > level if possible). > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Prototype & script.aculo.us" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en -~----------~----~----~----~------~----~------~--~---
