background preloader

Minify JavaScript - Free JavaScript Compressor

Minify JavaScript - Free JavaScript Compressor

Control Flow in Node Part II Static Version I had so much fun writing the last article on control flow, that I decided to play around with the feedback I received. One thing in particular I want to talk about is the good work inimino is doing. Node has two constructs that are used currently to handle async return values, namely callbacks and event emitters. UPDATE Promises were removed from node a while back, this article has been updated to show callbacks instead of promises. Why the distinction between Callback and EventEmitter? In node there are two event handling techniques. callback.js var fs = require('fs'); fs.readFile('mydata.txt', function (err, buffer) { if (err) { // Handle error console.error(err.stack); return; } // Do something console.log(buffer);}); fs.readFile() takes a filename and "returns" the contents of the file. Sometimes you want to listen for events that can happen several times. http-body.js var http = require('http'); console.log("Server started on continuable.js do.js

10 strike plan to grease your site for speed. - Webdistortion I’ve recently spoke of the importance of speed with your website or blog. It can have a significant impact on site goals, and in many cases improve bounce rates and increase page views. Paying attention to detail and improving page load speed can really get your pages performing at their optimum. 1) All Sites – on page speed Javascript Google host a variety of popular javascript libraries for web developers, and this standardised hosting platform provides a central repository for developers. This has a couple of benefits. 2) Images There are a number of way to optimise images for speed. I’ve found in the past the compression engine within Fireworks to be superior to Photoshop when analysing quality verses size. 3) Lowering web requests Web requests are individual web page calls to a web server for a file. You should do everything in your power to lower the number of requests that you make – the lower that number the better. 4) Client Side Compression 5) Server Side Compression Cache Plugins

jquery parse json multidimensional array - Minify Your Javascript/jQuery Code Online Slide Elements in Different Directions Although jQuery has a nice set of slide methods — .slideDown(), .slideUp(), and .slideToggle() — sometimes we may want to slide an element in a different direction. Fortunately, it's pretty easy to do. Reverse the Slide Direction With the built-in slide methods, elements are shown by sliding them down and into view. <div id="slidebottom" class="slide"> <button>slide it</button> <div class="inner">Slide from bottom</div></div> To get the inner div to slide up, we'll anchor its bottom edge to the bottom of the bottom of the nearest positioned ancestor (in this case, the #slidebottom div): Other properties such as width, padding, margin, and background-color have been set for these elements, but only the essential properties for modifying the slide behavior are shown above. Note: I'll be using the term positioned to refer to elements that have the CSS position property set to something other than "static." Now, we can write the jQuery the same way we would with a traditional slide effect:

Control Flow in Node Static Version One of the unique aspects of programming in an async framework like node is the ability to decide between which function will run in serial and which will run in parallel. While there are no built-in methods for managing this in node, I'll discuss some of the tricks I came up with while writing the node-blog engine that generates this site. Parallel vs Serial Usually in an application you have steps that can't run until the result from a previous step is known. This is the case in Node too, except for functions that would otherwise perform blocking IO. For my blog engine I have a tree structure of files that need to be processed. Get a list of articles.Read in and parse the articles.Get a list of authors.Read in and parse the authors.Get a list of HAML templates.Read in all the HAML templates.Get a list of static resource files.Read in the static files.Write article html pages.Write author pages.Write index page.Write feed page.Write static resources. simple-scanner.js

How do I force SSL on my ASP/.NET site on Cloud Sites? Below are three examples of how to force SSL on your ASP or ASP.NET site. web.config If your website has the IIS Rewrite Module available*, you can use rewrite rules in your web.config to force SSL on all pages: Please contact support if you are unsure if the IIS Rewrite Module is available for your site. The above example could be modified to force SSL on one page or specific pages. ASP.NET (Non MVC 3) Using ASP.NET you can use this code snippet to force SSL on a page on your site: When using the "RequireHttps" attribute to decorate actions within your MVC application: Classic ASP Using classic ASP you can use this code snippet to force SSL on a page on your site: © 2011-2013 Rackspace US, Inc. Except where otherwise noted, content on this site is licensed under a Creative Commons Attribution-NonCommercial-NoDerivs 3.0 Unported License See license specifics and DISCLAIMER

jQuery: The Write Less, Do More, JavaScript Library JSMIN, The JavaScript Minifier The JavaScript Minifier Douglas JSMin is a filter which removes comments and unnecessary whitespace from JavaScript files. What JSMin Does JSMin is a filter that omits or modifies some characters. JSMin first replaces carriage returns ('\r') with linefeeds ('\n'). It omits spaces except when a space is preceded and followed by a non-ASCII character or by an ASCII letter or digit, or by one of these characters: It is more conservative in omitting linefeeds, because linefeeds are sometimes treated as semicolons. and if it follows a non-ASCII character or an ASCII letter or digit or one of these characters: No other characters are omitted or modified. JSMin knows to not modify quoted strings and regular expression literals. JSMin does not obfuscate, but it does uglify. Before: After: Character Set JSMin requires, but does not verify, that the character set encoding of the input program is either ASCII or UTF-8. Caution Be sure to retain your original source file. a + ++b

demonstration Manipulation aisée de la DOM et des évènements jQuery permet une sélection aisée d'éléments de la DOM en utilisant les selecteurs, répondant à la syntaxe CSS et XPath. Pour plus d'information, rendez-vous sur la partie de la documentation consacrée aux sélecteurs.L'utilisation des évènements est également facile, avec des fonctions permettant d'assigner des fonctions à un évènement donné sur des élements. Exemple: Assignation d'une action sur un lien. Cliquez sur le lien pour déclencher l'action qui lui est associée. Lien de test //code HTML <a title="lien de test" id="lien_test">Lien de test</a> //code javascript $("#lien_test").click( function(){alert('bonjour !') Exemple: Assignation d'une fonction permettant de changer le style des élements de la liste d'id 'liste'. texte1 texte2 texte3 Les effets Test montrant l'effet 'FadeOut' / 'FadeIn' qui fait disparaitre un calque, avec la vitesse voulue. function testFade() { $('#effet).fadeOut("slow"); $('#effet).fadeIn("fast"); } Création de plugins

Prototypal Inheritance Static Version In almost all modern programming languages we use the concept of Object Oriented Programming (OOP) to help manage the complexity of today's software. The biggest challenge in modern software is in fact managing the complexity of it. Most languages do this with a variant OOP called Classical OOP. This is the one you see in Java, C#, C++, PHP, Ruby, and Python. While this is a great abstraction, I would like to experiment with other ideas. So what does JavaScript have? From what I hear (I wasn't there at the time), JavaScript was initially a prototypal inheritance system. Classical OOP classical.js var frank = new Person("Frank Dijon");frank.greet(); Output => 'Hello world, my name is Frank Dijon' Here we have a class like object Person. Prototypal OOP I don't like the new keyword, it overloads the meaning of functions and is dangerous. Instead try this on for size: prototypal.js#intro-to-style There is more you can set, but value and enumerable are the interesting ones.