Mailing List Archive
tlug.jp Mailing List tlug archive tlug Mailing List Archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]Re: [tlug] Javascript include order vs cat [SOLVED]
- Date: Sat, 18 Sep 2010 02:47:26 +0900
- From: Dave M G <dave@example.com>
- Subject: Re: [tlug] Javascript include order vs cat [SOLVED]
- References: <4C924ACE.9000707@example.com> <20100916170709.GI2124@example.com> <20100916215027.GA23445@example.com> <4C92CF23.60902@example.com> <4C92D5F5.7080506@example.com> <87vd64ygrs.fsf@example.com>
- User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.12) Gecko/20100826 Thunderbird/3.0.7
John, Stephen, Thank you for responding.I had an "includes.js" file which kept a list of all the Javascript I needed, in order, so I went with Stephen's idea of editing that file to create the properly ordered list.Took me a while to get the quotation marks properly escaped. Also I learned later that I could use anything as a delimiter on the sed command, which was important because the slashes I initially used were getting confused in combination with the slashes in the search string.I ended up with this (after some other operations on the file, it ended up as "includes.txt"):sed -i '/\/\// d' $DIR/javascript/includes.txtsed -i "s#document.write('<script type=\"text/javascript\" charset=\"utf-8\" src=\"#$DIR/#"g $DIR/javascript/includes.txtsed -i "s#\"></script>');##g" $DIR/javascript/includes.txtThe first line strips out comments, the next line strips out everything before the file names I want to keep and replaces it with an absolute path, and the third line takes out everything after.Then I took John's cat command with xargs, like this: cat $DIR/javascript/includes.txt | xargs cat > $DIR/all.js... and presto! The newly created mega-Javascript file works like a charm! The ordering issue has been resolved.I'm now also able to shrink it down from about 800 Kb to 500 Kb with YUI Compressor, which isn't bad. Really, though, the big time saving is simply not calling all the different Javascripts one by one when loading a page.My site now goes noticeably faster. Thanks, as always, to everyone for all the great help! -- Dave M G
- References:
- [tlug] grep, sed, and cat - oh my!
- From: Dave M G
- Re: [tlug] grep, sed, and cat - oh my!
- From: Nicolas Limare
- Re: [tlug] grep, sed, and cat - oh my!
- From: Mattia Dongili
- Re: [tlug] grep, sed, and cat - oh my! [SOLVED]
- From: Dave M G
- [tlug] Javascript include order vs cat (Was: grep, sed, and cat - oh my!)
- From: Dave M G
- [tlug] Javascript include order vs cat (Was: grep, sed, and cat - oh my!)
- From: Stephen J. Turnbull
Home | Main Index | Thread Index
- Prev by Date: [tlug] Debian rant
- Next by Date: [tlug] Debian rant
- Previous by thread: [tlug] Javascript include order vs cat (Was: grep, sed, and cat - oh my!)
- Next by thread: Re: [tlug] grep, sed, and cat - oh my!
- Index(es):
Home Page Mailing List Linux and Japan TLUG Members Links