Automatic javascript generation on constantly changing websites

This time I will discuss something I wrote for myself.

The problem:

I'm (and maybe you are) constantly developing my application, adding features and closing bugs, both to PHP and Javascript pages. When it comes to PHP, there is no issue, we simply update the last version to the server and forget about it.
With Javascript, however, this is a bit more complicated.

To fully understand the situation, place yourself into the CTO's shoes. We want bugs closed, we want new tricks and we want it to work and fast. When it comes to performance, the first (or second) rule in the book is to minimize and minify javascript files that the website works with. Why?

  1. Each javascript file we load with the <script> tag is actually causing the client's browser to create a separate request to fetch it. Multiple requests are huge overhead, that's why we want to load as little as possible JS files.
  2. Each javascript file contains unnecessary characters like newline, tabs, comment etc. Why not remove them? This process is called minification and it can shrink the JS file by 20-30% while keeping it fully functional. Great!

So here comes the real headache...
We develop and code and debug and test and finally, it's deployment time. But wait! Shouldn't we combine all out JS source files into one file? And why not minify it on the way? Doing this over and over for each small change, it a pain.
Furthermore, what about different sections on out app that require different JS scripts? We surely don't want to serve the client with scripts he doesn't need!

So here is my solution:

I created the JSLoader class, which takes care of generating a combined javascript files according to the JS sources needed for a specific section, minify it and serve it to the client. It will cache the combined JS files for later, so the same combinations will not be re-generated. Nevertheless, if you change one byte in any JS file, it will re-generate the appropriate files.

How do you use it? It's quite simple. You just have to be familiar with PHP5.


  1. Create a web-available folder for the generated Javascript files.
  2. Give the above folder write permissions for PHP.
  3. Copy the JSLoader package to your project or clone it from:
    git clone git://


1. First include or require the class file:
require_once '../lib/JSLoader.php';

2. Everywhere we want to use this class, we have to retrieve its instance:
$jsloader = JSLoader::getInstance();

3. Next, we do one-time configuration:

$jsloader->setJavascriptFolderURL('<a href="'">'</a>);

The first line sets the absolute path to where the combined JS files will be placed. The second line sets a web available URL to the same directory.

4. Now here is the real thing! Everywhere you want to “include” a javascript file, you do:

The above line should go each time you need to include a js file and you should pass the absolute path to that file. Also remember to retrieve the class’s instance when needed. See section 2.

5. Finally, you should place a <script> tag to include the generated combined JS file. Fortunately, JSLoader does it for you. Just place this code (once) where needed:

6. Check your page source to see if the file was included and that it’s available.


great blog

Нello! I simрlу wаnt to give you а big thumbs up foг the great informаtion you've got here on this post. I will be returning to your blog for more soon.

Also visit my page server for cardsharing

[p]Those days are gone when sun glasses ended up simply employed to take care of a people eye-sight from sun rays . Not absolutely everyone has exactly the same deal with shape and which is what helps make us all exclusive . Cheap Oakley Sunglasses - Greatest Sunglasses for Fashion Mindful Women

The first actually fashion house of luxurious ready-to-wear, Oakley has come quite a distance after [url=]cheap oakley sunglasses for men[/url] its inception within 1952 in Paris . Should you understand what the substantial or higher finish is you might have the ability to better shop for that reduced costs you need . These umbrellas are approximately, and tend to get [url=]cheap oakley polarized sunglasses

[/url] scaled-down in measurement having a flatter canopy . Keep in mind here that if impressing people is a concern the Oakley THUMP couldn't be more capable of the task . What comes to your mind while getting to know these free eyeglasses


If you this kind of people who work at computer for a lot of time each day, you must take care of your eyes [url=]cheap oakley sunglasses sale[/url] because computer radiation are likely to destroy your eyes . Oakley Sunglasses Sale

Related Articles - Oakley Sunglasses Sale, Oakley Sunglasses Cheap, Oakley Sunglasses Outlet,

Email this Article to a Friend!

Receive Articles like this one direct to your email [url=]cheap fake oakley sunglasses[/url] box!Subscribe for free today! . Step 2: Styles and features Various styles and features of Coach sunglasses must be studied through authentic catalogs.[/p][p]This is based about the company's stellar reputation [url=]cheap oakley sunglasses[/url] and nothing otherwise . A pair of Oakley sunglasses are an absolute must have for all who don't comprise in route they look . Truth be told, whether it??s the cool blue half jacket silver ice or the silver sunglasses, many work switches into making the fake oakley sunglasses look very, very real . Adjustable nose pads and wide temples offer a comfy fit . Therefore, if you have decided to purchase your pair, you can easily place an order from among the

nearest store of branded authentic designer sunglasses or buy one online . A one page would not be enough o covers the interesting facts about Oakley sunglasses . Early portable CD players were't actually all that portable ' If you had one and ever moved to sharply while using it you'll know what I mwean! Now with mp3 players & ipods there are no moving parts so you can listen when working out, running or anything else where a CD player would be useless . Retain in head that it really is essential that you just decide on a style that fits you and brings out the best of your facial functions.[/p]

Live Telecast of boxing match between Dereck Chisora vs.
Wladimir Klitschko
now easily obtainable online. Internet boxing fight
is available on your
personal computers from which you can record the stunning acts
which enable it to replay
the awesome actions perform with the boxer. All this is accessible to you at free
of cost and you'll be able to easily benefit from the live
performances without breaks and
intermission. There are numerous websites and software
available where you'll be able to
easily watch your struggle. The fight has grown to be more
interesting because the best
boxers will be in the ring now. Dereck Chisora,
the award winner of common
wealth games and so on the other side Wladimir Klitscho, powerful and vigorous
champion of the world will fight collectively and make a long lasting
When the both boxers appear in the ring and from their fighting
match the
fans is sure to become more excited and crazy to observe them and they also use
every source to possess one look of their live match.
Klitschko vs. Chisora
Live Stream might help the
viewers to see the live match at once without any interruption and
intermissions. If you desire to watch the match online at your home, with your
friends then you certainly should have your personal computer
and a good internet
connection. The fighters have got up many dangerous and
high fights and
every time their fans have praised their capability and performance.

The demand of online watch has grown these days and remember the
need and requirement of the general public many live stream sites and links ahs
established online that's easily accessible and viewable.
It’s became easy
for the public to view deadly boxing fights of their favorite fighter.

People are becoming very much habitual of fast internet technology that
don’t want to go to the stadiums and waste their amount of time in travelling for the
match. Not only the audio-visual data available on the internet, you can also leave
your comments and give ratings for your favorite
fighter as outlined by their
performance. If you are big fan of boxing and fighters don’t miss
to look at Klitschko
vs. Chisora Live Stream at
the period of fight.
No you can praise the efficiency in the fighters in words
as are the
best performers and possess great fan followings, which show their
capabilities and strengths. It can be seen and judged only by watching the

My blog; cool Sports online

Profitez d'une voyance 100% gratuite avec notre blog de médiums et
d'informations sur la vie spirituelle.
Une séance de voyance pourra très bien changer votre
façon de vivre, car qui connaît son avenir
profite mieux des petits plaisirs souvent négilgés.
100% des médiums de notre centre de divination ont de l'expérience dans la voyance amour et dans la voyance
de la vie professionnelle, et ils sont à votre disposition pour répondre à vos questions.

Ne réfléchissez plus, passez à l'acte et parlez à un des tarologues qui fait partie de notre cabinet
de voyance pour une consultation détaillée.

Exclusif pour les nouveaux membres, nous offrons la première consultation en privé selon les conditions stipulées.

Assess service and help deal from dealers.

Also visit my page :: frankingmachine

That was an excellent read through. I really like this website.
Thank you for posting about it.

Feel free to surf to my web blog :: las vegas classifieds (

all the time i used to read smaller articles or reviews which as well clear their
motive, and that is also happening with this
article which I am reading now.

Do you have a spam issue on this website; I also am a blogger,
and I was curious about your situation; many of us have developed some nice
methods and we are looking to exchange methods with other folks,
be sure to shoot me an e-mail if interested.

Visit my web page: Buy 1285 muscle

Hey would you mind stating which blog platform you're working with?
I'm looking to start my own blog in the near future but I'm having a difficult time choosing between BlogEngine/Wordpress/B2evolution and Drupal.
The reason I ask is because your layout seems different then most blogs and I'm looking for something completely
unique. P.S Sorry for being off-topic but I had to

That's a high-quality article. Everyone loves this web site.
Thank you for sharing with us.

Here is my web-site marketing firms las vegas, Valentina,

That is a wonderful article. I really like this
site. Many thanks for submitting.

Feel free to surf to my web blog :: Forget Ads Las Vegas

You really make it seem so easy together with your presentation but I to find this topic to be really something that I
believe I might never understand. It seems too complex and very vast for me.
I'm having a look ahead for your next submit, I'll attempt to
get the hang of it!

Currently it seems like Drupal is the top blogging platform available right now.

(from what I've read) Is that what you're using on your blog?

My blog post ... (

I'm not sure where you are getting your information, but good topic.
I needs to spend some time learning more or
understanding more. Thanks for great information I was looking for this info for my mission.

That was an awesome read. I love this web site. Appreciate your sharing.

Also visit my web-site ad agency las vegas

This was a first-class article. I really like this site.

I appreciate you blogging.

Here is my weblog; business consulting las vegas (

I'm really loving the theme/design of your weblog.
Do you ever run into anyy internet browser compatibility problems?
A few off my blog visitors have complained about my site not working correctly in Explorer
but looks great in Chrome. Do you have anyy recommendations
to help fix this issue?

my homepage :: clinique acne solutions post blemish formula reviews

This was a pretty good article. I love this website.
Thank you for submitting.

My web-site - seo companies

That's a superior article. I'm keen on this web site. Appreciate your writing.

Here is my webpage :: YouTube

Hello, i believe that i noticed you visited my website thus i came to go back the want?.I am trying to in finding things to
improve my site!I assume its good enough to use some of your concepts!!

Howdy! I could have sworn I've been to this web site before but after going through many of the posts I realized it's
new to me. Anyhow, I'm definitely pleased I discovered it and
I'll be bookmarking it and checking back regularly!

Also visit my blog post; Buy Supra Cleanse 350

Can you tell us more about this? I'd love to find out more details.

Look at my web site - muscle building program

I could not refrain from commenting. Very well written!

Feel free to surf to my blog post :: Virtual Office Address San Francisco

I got this web site from my pal who shared with me on the topic of
this website and now this time I am visiting
this web site and reading very informative content at this

My blog post ... body cleanser

Hello, I enjoy reading through your article. I
wanted to write a little comment to support you.

Amazing blog! Do you have any hints for aspiring writers? I'm planning to start my own blog soon but I'm a little lost on everything.
Would you propose starting with a free platform like Wordpress or go for a paid
option? There are so many options out there that I'm completely overwhelmed ..
Any recommendations? Many thanks!

It is not my first time to pay a visit this web page,
i am browsing this web page dailly and get good information from here daily.

This is the right blog for everyone who hopes to find out
about this topic. You know a whole lot its almost
tough to argue with you (not that I actually would want to…HaHa).
You definitely put a new spin on a topic that's been discussed
for many years. Great stuff, just excellent!

Hеllo! Ɗo you use Twitter? I'd like tօ follow yoս if tҺat աould Ƅе oҝ.
I'm absolutely enjoying yоur blog аnd lopok forward tto new posts.

ңave a look at mmy web-site ... city of ashes

I could not refrain from commenting. Well written!

Feel free to surf to my weblog :: Power IGF

I used to be suggested this web site by way of my cousin.
I'm now not certain whether or not this publish is written by him as nobody else recognise such particular about my problem.
You're amazing! Thank you!

Here is my web site: Muscle Rev X

Does your website have a contact page? I'm having a tough time locating it but,
I'd like to shoot you an email. I've got some creative ideas for your blog you might be interested in hearing.
Either way, great blog and I look forward to seeing it develop
over time.

Thanks designed for sharing such a fastidious thinking, post is nice, thats why
i have read it fully

I am not certain where you're getting your information, however good topic.
I needs to spend some time learning more or figuring out more.
Thank you for excellent info I was on the lookout for this info for my mission.

Everything is very open with a precise clarification of the challenges.
It was really informative. Your website is
very helpful. Thanks for sharing!

[p]The Author of this article is an expert on the latest trends pertaining to sunglasses . He has written many informative articles on various sunglass brands & products such as Fake oakleys, Replica Oakleys and Fake Oakley [url=]oakley prescription sunglasses sale
[/url] sunglasses . The Oval experience - with this particular type of encounter form, you can attempt on totally any type of Oakley sunglasses and be able to pull it off . A principal solution that will provide a person both of these exceptional possibilities is available with the investment into Oakley prescription glasses Boomstand . [url=]oakley sunglasses sale[/url] Nz . They not only protect the eyes from the harmful UV rays, but also make the wearer look kind of stylish, cool and mysterious . Some people have no trouble getting fake Oakleys or Foakleys as [url=]oakley polarized sunglasses sale[/url] they are termed just so they can preserve some green . You'll need a beautiful ladies Oakley sunglasses

In the actual morden society, when you are out, you will require a beautiful lady Oakley sunglasses, Which means that you can easily wait the greater expensive models, however, you may regret it when you are done checking away the store or even online . Optical technologies is exclusively utilised in oakley outlet to give a superior high quality of vision.[/p][p]Mens Oakley Sunglasses - Experience the Genuine Really worth

Oakley is popular globally for a collection of products like [url=]oakley polarized sunglasses[/url] footwear, watches, backpacks and sporting shirts, but they are very renowned and renowned for their desirable men's shades . Evening Bags - A Short History in Time . Related Articles - fake oakleys, foakleys, fake oakley sunglasses, cheap oakley sunglasses,

Email this Article to a Friend!

Receive Articles like this one direct to your email box!Subscribe for free today! . com

Sunglasses are very popular fashion status symbols . Verify out the Oakley polarized sunglasses, I feel you could be pleasantly impressed . Inexpensive Oakley Sunglasses

You prefer to travel? Do you need to sell things? If that's the case, why not close to sunglasses wholesale product sales, in fact, promote their very own travel . Cheap Oakley [url=]oakley prescription sunglasses[/url] Sunglassesmade headlines recently with its donation of 35 pairs of "Radar" sunglasses to the Chilean miners to protect their eyes upon their escape from their cave after 66 days underground . It is my private impression but I just don't see how you can help save money buying fake Oakleys time and time yet again as opposed to acquiring genuine ones an individual time.[/p]

As the admin of this web page is working, no doubt very soon it
will be well-known, due to its quality contents.

Nice pos&X74;. I wa&X73; checkіng contin&X75;ously &X74;his &X62;log and ӏ am impressed!
Extremely hе&X6C;p&X66;ul info part&X69;culaгly&X74;he last pаrt :) I
care for such info a lot. I was seekі&X6e;g &X74;hіs pаrticular inf&X6f; for a νery long tіmе.

Thank you аn&X64; best of luck.

Feel frеe to surf &X74;&X6f; mу web b&X6c;og :
: robert sigg

Fascіnating blog! Is yoսr tɦеme custom made or did you download it
from somewhere? A themе like yours with a few simple tweeks would really
make my blog stand out. Please let me know where yoս got your theme.

Its such as you learn my mind! You appear to know a
lot approximately this, such as you wrote the e-book in it
or something. I think that you simply could do with some p.c.
to power the message home a little bit, however
instead of that, this is excellent blog. A great read. I will definitely
be back.

That was a beneficial read through. I really enjoy this blog.
Many thanks for posting.

Look into my web page :: nevada seo (

Printing them on demand is the cost-effective way to go.

It is considered as timeless message. Allow to dry and glue together into
a circle, layering the pieces.

Yes! Finally something about online business.

You actually make it appear really easy with your presentation however
I find this topic to be really something that I believe I
might never understand. It kind of feels too complex and
extremely vast for me. I am having a look ahead for your subsequent put up, I will attempt to get the
dangle of it!

Feel free to visit my blog ... Formula T10

Your method of describing all in this article is truly fastidious, every one be able to
easily understand it, Thanks a lot.

Here is my webpage; Google

you're actually a just right webmaster. The site loading speed is incredible.
It kind of feels that you are doing any unique trick. Furthermore,
The contents are masterwork. you have done a excellent process in this subject!

I do not even understand how I finished up here, but I assumed this submit was good.
I don't realize who you're however certainly
you're going to a well-known blogger in case you are not already.

I every time emailed this webpage post page to all my contacts, because if like to read it next my links will too.

Feel free to visit my web site :: lucy full movie


Add new comment