Octopus Paul: Spanje wint WK voetbal

Misschien kunnen we Paul samen met de Duitsers grillen en dan oppeuzelen.
Of je kunt geloven dat de enige ware voorspeller een parkiet is.
Deze website ziet er kruk uit in jouw webbrowser. Lees hier waarom »

Misschien kunnen we Paul samen met de Duitsers grillen en dan oppeuzelen.
Of je kunt geloven dat de enige ware voorspeller een parkiet is.
I wrote a (very) small Javascript function to dynamically load Javascript files. In modern Javascript development you usually have more than one Javascript file in your page (e.g. jQuery, a few plugins, a main javascript file) that depend on each other. Loading them using the <script> tag works, but sometimes you get a dependency problem because scripts are not guaranteed to load from top to bottom in the order they appear in on the page.
The script is based on this version by Nicholas C. Zakas but adds an extra option to load an array of Javascript files.
Fork it on Github or get a minified version.
Here’s how you use it:
// Loading a single file
jsDynaLoad("single.js", function() {
alert("callback after the single file");
});
// Loading an array of files
var files = ["1.js", "2.js"];
jsDynaLoad(files, function() {
alert("callback after the array of files");
});
// A callback is not required
jsDynaLoad("nocallback.js");
To get a better performance remember to place your scripts at the bottom of your page, close to the closing </body> tag. You can also include the minified version of loadScript inline in a <script> tag to save a HTTP request.

When using Freemarker in Magnolia, you often get errors. For example, because you tried to use an undefined value and didn’t add the required ‘!’ symbol. When that happens you see the infamous red-on-yellow “FreeMarker template error!”. During development, that’s not a problem, but on a production site you don’t want to confuse your visitors with cryptic Java errors.
Unfortunately, it’s not that easy to turn those errors off, and you probably do want people to report these errors because they might indicate a serious bug in your website.
For this purpose i wrote a small Javascript function that you can use to ‘prettify’ the Freemarker error. It replaces the stacktrace with a general error message, but the user can still see the original error by clicking on a link. The script requires jQuery, which is included in the STK or can be downloaded from jQuery.com. To run in, just add it to your $(document).ready() function.
To view the script read the Magnolia wiki page.
» Een overzicht van alle artikelen vind je in het archief.
Hallo! Ik ben Hay. Ik maak kunst, doe projecten en blog hier. Lees verder »