Hello, While this is my first post on this forum, I''ve been looking at Prototype seriously for the past 3-4 months. So far, it seems to have everything I need. I''ve been looking at developing a web framework and my Javascript needs are more than satisfied by Prototype. But that''s the problem. I do not need all of Prototype.js. So I was wondering if it is possible and viable to try and break up the JS file into multiple parts. The reason I ask is because the js file is more than 3000 lines long (I''m looking at 1.5+). I have to believe the browser spends some time fetching this file from the server. Given that I would only like to deliver and use those parts of Prototype that I have use for, I''m thinking my pages will load faster if I break up the file. Needless to say I will need to spend some time looking at the js file in detail to "see" how things work before I can chop the file into chunks. I was wondering if anyone has looked into this. I was even thinking of deleting some functions that I don''t need in order to reduce the size. Which brings me to my final questions. I will surely end up delivering a JS file to my browser users which will not be the original Prototype.js. In that case, should I call it Prototype.js? I would think not. Besides I''m not sure if this is in violation of the license - if I change the contents, am I required to change the filename? Also, regardless, I want to give credit where credit is due as long as it does not confuse anyone looking at how things are implemented. How do I manage to do so? Any hints, suggestions, usage etiquettes from Prototype users would be very helpful. Thanks in advance for your time and help. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
Don''t try to optimize the wrong thing. Just serve the file gzipped and with proper caching and expiration headers. gzip usually yields a 1:4 or 1:5 compression ratio on JavaScript, and the headers will make sure the file is only downloads once while the user stays on the site (or returns to it). _Breaking it up_ in more than one part will _actually slow everything down_, as the browser will make multiple connections to the web server, and they only occur after each other. It depends on your server-side software on how to enable this, but here''s a starting point: http://www.thinkvitamin.com/features/webapps/serving-javascript-fast Best, Thomas Am 13.08.2007 um 16:39 schrieb PrototypeWannabe:> > Hello, > > While this is my first post on this forum, I''ve been looking at > Prototype seriously for the past 3-4 months. So far, it seems to have > everything I need. > > I''ve been looking at developing a web framework and my Javascript > needs are more than satisfied by Prototype. But that''s the problem. I > do not need all of Prototype.js. So I was wondering if it is possible > and viable to try and break up the JS file into multiple parts. The > reason I ask is because the js file is more than 3000 lines long (I''m > looking at 1.5+). I have to believe the browser spends some time > fetching this file from the server. Given that I would only like to > deliver and use those parts of Prototype that I have use for, I''m > thinking my pages will load faster if I break up the file. > > Needless to say I will need to spend some time looking at the js file > in detail to "see" how things work before I can chop the file into > chunks. I was wondering if anyone has looked into this. I was even > thinking of deleting some functions that I don''t need in order to > reduce the size. > > Which brings me to my final questions. I will surely end up delivering > a JS file to my browser users which will not be the original > Prototype.js. In that case, should I call it Prototype.js? I would > think not. Besides I''m not sure if this is in violation of the license > - if I change the contents, am I required to change the filename? > Also, regardless, I want to give credit where credit is due as long as > it does not confuse anyone looking at how things are implemented. How > do I manage to do so? Any hints, suggestions, usage etiquettes from > Prototype users would be very helpful. > > Thanks in advance for your time and help. > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
That is a very interesting article. Just to clarify, I might have misspoken when I said chopping the js file into junks for delivery. I meant I would only always have only ONE file. It would just not be the entire Prototype.js file which is almost 100KB in size. Maybe I can use some compression program to remove whitespaces which should reduce the size. Thanks! This definitely gives me some food for thought. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
On 13.8.2007, at 18.43, PrototypeWannabe wrote:> That is a very interesting article. > > Just to clarify, I might have misspoken when I said chopping the js > file into junks for delivery. I meant I would only always have only > ONE file. It would just not be the entire Prototype.js file which is > almost 100KB in size. Maybe I can use some compression program to > remove whitespaces which should reduce the size.Don''t bother, gzip will do that for you anyway if you follow Thomas'' instructions. //jarkko -- Jarkko Laine http://jlaine.net http://dotherightthing.com http://www.railsecommerce.com http://odesign.fi
Looks like it. I tried to use "ShrinkSafe" on the Dojo site as also suggested in that article. I dunno if anyone has tried applying it on Prototype.js. I tried to apply it on this URL http://alex.dojotoolkit.org/shrinksafe/ I checked the "strip newline chars" option. I got absolute garbage toward the end of the compressed version. Thanks all. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---