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

I’m not that much of a internet reader to be honest but your
blogs really nice, keep it up! I'll go ahead and bookmark your website to come back
down the road. Cheers

Also visit my homepage; London Asian massage (Major)

This article offers clear idea for the new users of blogging, that
truly how to do blogging and site-building.

Take a look at my web site: Central London Asian massage - Maxine,

Hi mates, nice piece of writing and good arguments commented at this place, I am in fact enjoying by these.

You ought to take part in a contest for one of the greatest blogs online.
I will recommend this website!

Wow, that's what I was seeeking for, what a data!
present here at this webpage, thanks admin oof this web site.

Alsso visit my webpage summoners war Sky arena Hack

I could not refrain from commenting. Very well written!

Visit my web site; escorts in Kent - -

Greetings! I've been following your site for a long time now
and finally got the bravery to go ahead and give you a shout out from Houston Texas!
Just wanted to say keep up the good work!

beats mixr headphones
I truly love your blog.. Great colors & theme.
Did you create this amazing site yourself? Please reply back as I'm planning to create my
own site and would love to find out where you got this from or exactly
what the theme is called. Thank you!

Découvrez l'inconnu grâce une examen de voyance web Elle-même vous-même
aide dans vos choix professionnels, sentimentaux ensuite relationnels.

En décrivant vos émotions, votre vie sociale ensuite amoureuse, la voyance web démêle l'écheveau
compliqué de votre existence quotidienne. Ce localisation toi révèlera les bienfaits dont peut apporter la voyance
web gratuite supposé que toi optez près cette examen ensuite dans vos
recherches de voyants réputés. In extenso les jours,
rare voyante spécialiste de la voyance web répond à toutes vos devinette en clair.
Voyance TV, radiographie ou web, toutes les voyantes que vous trouverez sur notre réunification ont rare expérience lequel leur permet de traiter les accroc ces
davantage difficiles. Voyance directe. Rare vrai examen par SMS.
Chat medium ( état web ) Ceci 23/03/2011

I սsed too bе suggested tɦis website through mу cousin. Ӏ
am nno lοnger certtain ѡhether or not thіs publish is written Ьy means
off him aѕ nobody else recognise sսch particular
approximately mmy problem. You're amazing! Thanks!

Mү website - Gatorade Coupons august 2012

Excellent site. A lot of useful information here.
I'm sending it to several pals ans also sharing in delicious.
And naturally, thanks on your effort!

I want to to thank you for this wonderful read!!
I absolutely loved every little bit of it. I have you bookmarked to look at new things you post…

Feel free to surf to my weblog atvs polaris

Every weekend i used to paay a visit this web site, ƅecause і wіsh for enjoyment, as tɦіs
thіs webb page conations genuinnely nice funny data tօo.

Alsο visit myy webpage - fescue lawn (

Heya i'm fߋr thе fiгst time heгe. I camne aϲross tɦiѕ board ɑnd I
in finding It truly helpful & it helped mme оut a lot.
I'm hoping to provide ѕomething back and aid оthers such ɑs you heelped mе.

I've read a few excellent stuff here. Definitely value bookmarking
for revisiting. I wonder how a lot effort you put to create such a
excellent informative site.

I want to to thank you for this fantastic read!! I definitely enjoyed every little bit of it.
I have you book-marked to look at new stuff you post…

Here is my web page massage canary wharf (

Asking questions are truly nice thing if you are not understanding something entirely, but this article offers pleasant understanding yet.

I loved as much as you will receive carried out right here.
The sketch is attractive, your authored material stylish.
nonetheless, you command get got an nervousness over that you wish be delivering the
following. unwell unquestionably come more formerly again as exactly the same
nearly very often inside case you shield this hike.

Look into my page: plumbing tips,,

The job of a lawyer is not an easy cake walk but one has to actually
undergo years of studies in order to get the degree of personal injury lawyer.

You probably already know that getting divorced can be expensive.
Personal injury solicitors are people represent clients who've been injured, or whose injuries have been completely worsened,
by others becoming negligent.

Wow that was odd. I just wrote an incredibly long comment but after I clicked submit my comment didn't show up.
Grrrr... well I'm not writing all that over again. Regardless,
just wanted to say wonderful blog!

Have a look at my website :: self improvement - Maddison -

Do you mind if I quote a couple of your articles as long as I provide credit and sources back to your webpage?
My blog site is in the very same niche as yours and my users would really benefit from some of the information you present here.
Please let me know if this ok with you. Regards!

I read a lot of interesting posts here. Probably you
spend a lot of time writing, i know how to save you a
lot of work, there is an online tool that creates high quality, google friendly articles in minutes,
just type in google - laranitas free content source

I was recommended this web site by my cousin. I'm not sure whether this post is written by
him as nobody else know such detailed about my trouble.
You are incredible! Thanks!

Visit my site :: carb nite solution free pdf

replica chanel handbags outlet
Hello, Neat post. There is an issue along with your site in web explorer, might test this?
IE nonetheless is the market leader and a good
part of other folks will omit your fantastic writing due to this

Isabel Marant Heels Isabel Marant Pumps xQGpF Corrispondenza dei
colori è sempre discreta ma maniera impressionante abbastanza forte.
Anche un semplice stile della borsa, si può sentire molto affascinante marchio Burberry, così come due
stili di sacchi neri sono anche moda e di lusso..
Isabel Marant Heels Isabel Marant Pumps nlZYo Il tumore contiene solo tre
disposizioni. Cambia la provinciale legge sui diritti umani per proteggere le persone sia perseguita o
sanzionata da una commissione sui diritti umani per l'espressione o l'esercizio di convinzioni opposte a matrimonio dello stesso sesso.
Isabel Marant Pumps Isabel Marant Heels HrDGR Dato che le
nostre tasse sono sempre lavati con i soldi per aiutare le famiglie ad affrontare, e tuttavia morgtages.
Inoltre, le banche ci darà indietro i soldi con gli
interessi, ma ovviamente dovete considerare.
Isabel marant pumps Isabel Marant Boots lnaCX Parks non sanzionate abbondano nei pressi dello stadio, la gente che contengono un rischio sjfren. Parcheggio Hkan assicurazione non necessario,
Hkan essere esposto al furto di un veicolo incustodito, o anche gradi
di configurazione di pericolo Hkan mal aree illuminato mentre
g da e per i luoghi. Isabel Marant Heels Isabel Marant Sneakers IuJqX File in questo Products
novembre a ruba presso i magazzini di Amazon tutta la contea come californiani si preparano a iniziare a pagare l'imposta sulle vendite per gli acquisti on-line.

La modifica, che entrerà in vigore Sabato, Settembre emendamento, che entra
in vigore questo fine settimana, arriva dopo anni di amaro avanti e indietro tra i mondi più grande
centro commerciale online e il California legislatura il fatto che i rivenditori di Internet dovrebbero far pagare

Isabel Marant Pumps Isabel Marant Boots vwabr Quando il vapore si schiarì, e
ho visto persone che erano con me. E 'strano vedere la sua famiglia e provare a immaginare che aspetto strano.

Isabel Marant Heels Isabel Marant Pumps zVLwM SA ha detto Miller, diritto non è trasferibile e kommisjonr e
proprietari eh ripetizioni che possono trovare modi
per proteggere i fan rispettando esperienza superiore giorno di gioco.
Custodia tipo usato negli attentati di Boston è già stato bandito dagli stadi NFL, la gente ha detto che saranno ammessi borse di dimensioni Miller nello stadio era un Accovacciato più in alto.
Isabel Marant Sneakers Isabel Marant Heels zZdNt Il signor Fraser osserva che vi è una tendenza generale ad aumentare le scuole adottare divise in generale, non solo nelle
scuole private, ma gli enti pubblici e cattolici anche.
È interessante notare che, quando era studente a Appleby stessa,
19781987, era un anziano gli studenti sono autorizzati ad indossare giacca e cravatta per la
loro scelta, purché soddisfi determinati requisiti.

Hеllo, jst ԝanted to ѕay, I loved tɦis blog post.
It ѡaѕ inspiring. Kеep on posting!

my bkog ... nabisco 100 calorie packs Coupon

Hello, i think that i saw yoս visited my site thսs і сame to “return tɦe favor”.ӏ'm tгying to fіnd thіngs to enhance my web site!ӏ suppose its oқ to usе а feԝ of
youг ideas!!

my web blog Https://Ssl.Qwws.Net/Trac/Dy_Xtreme/Ticket/4102

prada bags 2015
It's very effortless to find out any matter on net as compared to books, as I found this paragraph at this web site.

I always spent my half an hour to read this website's content everyday along with a cup of coffee.

Lokale und globale Online-Kleinanzeigen Gratis Werbung
Lokalne i globalne Online Ogłoszenia Bezpłatne ogłoszenia
La nivel local și la nivel mondial Online Mica publicitate gratuit Publicitate
Локальна і глобальна онлайн Оголошення Безкоштовна реклама
المحلية والعالمية على الانترنت الاعلانات المبوبة
إعلانات مجانية
Local y global en línea clasificados Publicitarios
Lokal dan global online Iklan Baris Gratis Iklan

Wow! At last I got a website from where I can truly get valuable facts concerning my study and knowledge.

My web blog: click

louis Vuitton handbags online
I needed to thank you for this wonderful read!! I certainly enjoyed every little
bit of it. I've got you book-marked to check out new things you post…

I visited multiple blogs except the audio quality for audio songs current
at this web page is actually superb.

Wɦаt і dο not rsalize is in truth ɦow you are not really a lot more smartly-lіked than you
might Ьe right now. Υoս ɑre ѕο intelligent.
Yоu recopgnize tɦerefore ѕignificantly in relation tο this matter, maɗe me foг mmy part consider it fгom sso
maqny varied angles. Ӏts like men and women aren't fascinated
except it is somеtɦing to accomplish wiyh Woman gaga!
Yoour personal stuffs nice. Αlways handle іt

Feel free tο surf to mƴ weblog utahfirearmclassifieds.Com

I'll immediately grasp your rss as I can not find your e-mail subscription hyperlink or newsletter service.
Do you have any? Kindly allow me understand in order that I may just subscribe.

I do consider all of the ideas you have presented in your post.
They are very convincing and can certainly work. Nonetheless, the posts are very brief for starters.
May you please prolong them a little from subsequent time?
Thanks for the post.

Why users still make use of to read news papers when in this technological globe the whole thing is available on web?

rolex yachtmaster ii watches
I seriously love your site.. Very nice colors & theme.
Did you make this web site yourself? Please reply
back as I'm wanting to create my own website and would love to
learn where you got this from or just what the theme is called.

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

I love what you guys are usually up too. This kind of clever work and reporting!
Keep up the fantastic works guys I've included you guys to blogroll.

Feel free to visit my web blog life and business coaching melbourne,

Hello, Neat post. There is an issue together with your web
site in web explorer, may test this? IE nonetheless is the market leader and a huge portion of people will miss your fantastic writing because of this problem.


Add new comment